unplugin / unplugin-vue2-script-setup

💡 Bring `<script setup>` to Vue 2.
MIT License
603 stars 39 forks source link

来自vue-router (3.4.9) 的props似乎无效 #126

Closed isanonymous closed 2 years ago

isanonymous commented 2 years ago

来自vue-router的props似乎无效

https://v3.router.vuejs.org/zh/guide/essentials/passing-props.html

路由定义

{
  path: '/my_path',
  component: MyComp,
  props:rt=> {return ({dId:rt.query.dId, name:rt.query.name, code:rt.query.code})},
}

传参代码

setup(props, {attrs, emit, slots, root} ) {
  root.$router.push({path:'/my_path', query:{dId:'row.id', name:row.equipmentName, code:row.equipmentCode}})
}

// props中的3个属性都为undefined

vue代码

// 在<script  setup>中
const props = defineProps({
  dId:{type:String, required:true},
  name:{type:String},
  code:{type:[String,Number]},
});
// props中的3个属性都为undefined
console.log("---proops---", props);