webpack + Vue 父组件传值给子组件,子组件传值给父组件

    技术2022-07-15  85

    ———————————————父组件传子组件————————————————————— 父组件 <DeviceUpdate :childImgUrl="childImgUrl"/> import DeviceUpdate from './devicearrivecheckdetail-upload' export default { components: { DeviceUpdate }, data () { return { childImgUrl:"父组件向子组件传值" } } } 子组件 <template> {{childImgUrl}} </template> export default { props:{ childImgUrl:{ type:String, required:true } } } ———————————————子组件传父组件————————————————————— 父组件 <DeviceUpdate @getMessage="getVal"/> import DeviceUpdate from './devicearrivecheckdetail-upload' export default { components: { DeviceUpdate }, methods: { getVal(msg){ this.dataForm.acceptImgUrl +=msg; } } } 子组件 <template> {{childImgUrl}} </template> export default { methods: { function(){ this.$emit('getMessage',this.fileListUrl); } } }

     

    Processed: 0.011, SQL: 9