$refs的用法

1.首先自己去拉2个公共组件进来:
<div>
    <Editor ref="details"></Editor>
    <Table ref="mainTable"></Table>
</div>
2.$refs的作用主要是能调用到组件里面的方法 和 与getElemById一样获取这个标签
methods:{
getContent(){
        console.log(this.$refs); //这里打印的就是一系列的带有ref属性的组件构成的对象
        this.$refs.details.getContent(); //这里就可以使用editor的getContent方法了
    }
}

猜你喜欢

转载自blog.csdn.net/ljw_jiawei/article/details/80292056
今日推荐