You are viewing a single comment's thread from:

RE: Vue.js实战笔记

in #starnote4 years ago

主要是通过 $refs 获取子组件对象

  1. 绑定属性
  2. 获取子组件对象
//Test.vue
data(){
 return {
   str:'',
   sonmsg: '这是子数据'
 }
},

// App.vue
<Test ref="sonmsg"></Test>  // 1. 绑定属性
mounted() {
 console.log(566, this.$refs.sonmsg.sonmsg) // 2. 获取子组件对象
}