vue中this.$refs可以拿到,但是里面的属性undefind的问题


1.和vue的生命周期有关,必须要在从mounted开始拿,才能拿得到里面的Dom元素

2.想在element ui 对话框打开后取dom时,应该使用$nextTick,而不是直接使用this.$refs. imgLocal2

        console.log('this.$refs.imgLocal2外面', this.$refs.imgLocal2); setTimeout(() => { console.log('this.$refs.imgLocal2 setTimeout', this.$refs.imgLocal2); }, 500); // 不推荐 this.$nextTick(() => { console.log('this.$refs.imgLocal2 $nextTick', this.$refs.imgLocal2); });


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM