I want a piece of rich text to be rendered in vue, but this rich text contains a script
statement. I tested it locally and did not execute the statement.
How to solve this problem?
Sample code:
<template>
<p v-html="testHtml"></p>
</template>
<script>
export default {
data () {
return {
testHtml: '<p><script>console.log("test")</script><p><span>测试测试</span></p><p>'
}
}
}
</script>
Thank you~
过去多啦不再A梦2017-06-26 10:58:14
No, vue
will not render the script
tag in the page. I want to insert a third-party advertising script. You have several ways
Rewrite a page, vue
load this iframe
, this performance will be poor, you can use the srcdoc
attribute of iframe
, it will be better
If it must be inserted into the page, then after the list rendering is completed, pass document.createElement('script')
, and then append
enter the page
给我你的怀抱2017-06-26 10:58:14
Post the code and look at the problem description. Isn’t it a good idea to write like this