这也是调用子组件的方法
<input type="button" value="调用" @click="getElement">
<h3 ref="myh3">天天这样</h3>
getElement: function () {
console.log(this.$refs.myh3.innerText)
}
//如果是循环中使用$refs(v-for),那么它的元素会是一个数组!
<div v-for="">
<mavon-editor v-model="body" ref="mds" @imgAdd="upimg" style="height: 100%"/>
<div>
//mds: Array(3)
0: VueComponent {_uid: 91, _isVue: true, $options: {…}, _renderProxy: Proxy, _self: VueComponent, …}
1: VueComponent {_uid: 102, _isVue: true, $options: {…}, _renderProxy: Proxy, _self: VueComponent, …}
2: VueComponent {_uid: 113, _isVue: true, $options: {…}, _renderProxy: Proxy, _self: VueComponent, …}
length: 3
RE: Vue.js实战笔记