vue ref和$refs 获取不到值
父级用this.refs获取子组件中的数据,打印console.log(this.refs获取子组件中的数据,打印console.log(this.refs获取子组件中的数据,打印console.log(this.refs)有一个东西出现,但是console.log(this.$refs.name.functione()) undefine; 之前调用其他组件的时候并没有发现这样的问题。原因:要在
·
父级用this.refs获取子组件中的数据,打印console.log(this.refs获取子组件中的数据,打印console.log(this.refs获取子组件中的数据,打印console.log(this.refs)有一个东西出现,但是console.log(this.$refs.name.functione()) undefine; 之前调用其他组件的时候并没有发现这样的问题。
原因:
要在子组件挂载完成时this.$refs.name.functione()才可以生效
解决方式:
this.$nextTick(() => {
this.$refs.name.functione()
})
更多推荐
所有评论(0)