mounted使用$refs结果为undefined
<div>
<aplayer ref="mus" :music="songs[0]" :list="songs" showLrc="true" theme="red"></aplayer>
</div>
在上面的代码中使用了ref
getid () {
this.id = this.$refs.mus.music.id;
}
在mounted中调用上面的函数,却显示
最后通过查阅资料,可能的原因是在mounted阶段并没有对aplayer进行渲染,但是在updated阶段是会对所有的DOM节点进行渲染的。
所以,最后是将mounted改为了updated,才解决了问题。