1. The last level of the el-cascader control is blank and there is no data
Reason: The children array of the last level of data is empty
2. Solution: Use recursion to set the children in the bottom layer to undefined
getTreeData(data) {
for (let i = 0; i < data.length; i++) {
if (data[i].children.length < 1) {
// 最后一级没有数据将children变成undefined
data[i].children = undefined;} else {
// children不为空时继续调用该方法
this.getTreeData(data[i].children);
}
}
return data;
},
3. Call the method to change the original data
The method of removing HTML tags from a string to get plain text:
Use .replace(/<[^>]*>/g, '')
var myHTML= "<div><h1>卡卡网</h1>\n<p>www.webkaka.com</p></div>";
var strippedHtml = myHTML.replace(/<[^>]+>/g, '');
console.log(stripedHtml);