方案1
可以在mounted中挂载
1
2
3
4
5 mounted:function(){
this.$nextTick(function(){ //this.$nextTick是在下次DOM更新循环结束时调用延迟回调函数。异步函数
this.loadData(); //DOM加载就绪,后调用loadData方法进行数据更新<br> //想要更新后的获取dom //此时若获取更新后dom数据将会报错,数据为undefined;
})
}
方案2
1 | if(document.addEventListener){ |