clickList(event) { var node = this.$refs.msg.childNodes var curr = event.currentTarget for (var i = 0; i < node.length; i++) { if (node[i].nodeName != ‘#text‘) { if(node[i] == curr){ node[i].classList.add("code"); }else { node[i].classList.remove("code"); } } } },
if (node[i].nodeName != ‘#text‘) 去除空白节点
node[i].classList.add("code"); 添加指定class
node[i].classList.remove("code"); 删除指定class