解构赋值在代码里面会被vscode报错
然后在浏览器确实会报错
Uncaught SyntaxError: Unexpected token '...'
compile(fragment) {
//1.获取子节点
const childNodes = fragment.childNodes
console.log([...childNodes]);
[...childNodes].forEach(child => {
console.log(child);
if (this.isElementNode(child)) {
console.log('元素节点', child);
} else {
console.log('文本节点', child);
}
})
}
如果事先去log一下这个数组 就不报错 也正常运行了 这是什么原理
上一行加一个分号就可以了。