一:自定义事件传值
父组件:
<template>
<view>
<productionSchedule :nowProId='nowProId'></productionSchedule>
</view>
</template>
<script>
import productionSchedule from '../productionSchedule/productionSchedule.vue';
export default {
components: {
productionSchedule,
},
data() {
return {
nowProId: ''
}
}
}
</script>
建议方法名和数据名一样,项目大数据多之后不会乱。
子组件:
data() {
return
}
},
props: {
nowProId: {
type: String,
default: ''
}
},
创建与data同级的props接收传过来的数据。
然后在项目中this.XXX就可以使用变量值。