本文主要是介绍webpack + Vue 父组件传值给子组件,子组件传值给父组件,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
———————————————父组件传子组件—————————————————————父组件<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);}}
}
这篇关于webpack + Vue 父组件传值给子组件,子组件传值给父组件的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!