我遇到了一个错误,其中计算未定义,我似乎无法找到如何解决这个问题,即使将其放入computed: {}
<template>
<component :is="tag" v-html="sanitizedContent" />
</template>
<script>
import { defineComponent } from "@nuxtjs/composition-api";
import DOMPurify from "isomorphic-dompurify";
export default defineComponent({
name: "HTMLContent",
sanitizedContent: computed(() => DOMPurify.sanitize(props.content)),
props: {
tag: {
type: String,
default: "div",
},
content: {
type: String,
default: "",
},
},
});
</script>
Run Code Online (Sandbox Code Playgroud)