起因:引入js文件中含有innerHTML,直接引入之后報錯Cannot set property 'innerHTML' of null。
原因:vue生命周期樹順序先編譯了js文件,還沒有東西所以null
我的解決:
1.把js內容放函數aa()中
2.寫入methods()中
methods: {
aa() {
xxxxxx
}
}
3.在mounted中 this.aa()
mounted() { this.aa() }, //dom掛載后生命周期
其他: