vue3获取页面参数的方式和vue2是不一样的,下面是vue3或者路由参数的方式:
传入参数页面:
<el-button size="mini" type="success" @click="$router.push({path:'form',query:{id:row.id,nickname:row.nickname}})" > 编辑 </el-button>
获取参数:
<script> import { defineComponent, ref, reactive } from 'vue' import { onMounted} from 'vue' import {useRouter, useRoute} from 'vue-router' export default defineComponent({ name: '操作表单', components: { }, setup(props) { const router = useRouter(); onMounted(() => { console.log('query',router.currentRoute.value.query) //query {id: '108761', nickname: '用户028060'} }) return { } } }) </script>