vue-dompurify-html@2.5.2 //这是支持vue2最后一个版本
方法一:
<script src="https://cdn.jsdelivr.net/npm/vue-dompurify-html@5.0.1/dist/vue-dompurify-html.umd.min.js"></script>
方法二:
//main.js
import VueDOMPurifyHTML from 'vue-dompurify-html'
Vue.use(VueDOMPurifyHTML)
<template>
<div v-dompurify-html="rawHtml"></div>
</template>
<script setup>
import { ref } from 'vue';
const rawHtml = ref('<span style="color: red">This should be red.</span>');
//vue2
data(){
return{
rawHtml:'<span style="color: red">This should be red.</span>'
}
}
https://www.npmjs.com/package/vue-dompurify-html?activeTab=readme