父传子:
父组件:
<view-doc :openDialog="openDialog"></view-doc>
import viewDoc from './components/viewDoc' components: { 'view-doc': viewDoc, }, data () { return { openDialog:'123' } }
子组件:
props: { openDialog: Object }, watch: { 'openDialog.formData' (msg) { console.log(msg) this.form = { mobile: msg.mobile, email: msg.email, name: msg.name, note: msg.note, } } }
子传父:
父组件:
<view-doc v-on:childByValue="childByValue"></view-doc>
import viewDoc from './components/viewDoc' components: { 'view-doc': viewDoc, }, childByValue: function (childValue) { // childValue就是子组件传过来的值 console.log(childValue,'值') },
子组件:
<el-button type="primary" @click="submitMessage">确定</el-button>
submitMessage () { console.log(this.getCheckMessage) this.$emit('childByValue', this.getCheckMessage) },