let str = "<img :src=('face[k].src)>"
this.commentList[i].Content = this.commentList[i].Content.replace(sArr[j], str)
The requirement is to convert the string in str into html output. This img is an expression. Check whether the returned content contains an expression, and then replace it. If I output it like this, it is just a string. How can I convert it to html? ? It seems that the eval() method is not supported
As follows, after obtaining the data, you should modify the Content to html and bind it using the v-html command:
--- Supplement ---
The second parameter of the .replace() method also supports the use of function returns, which can achieve more complex replacements, such as:
v-html?
It is recommended to use
v-if
BetterUse innerHTML for native, html() for jq;
Has anyone encountered the same problem~