import { createApp } from 'vue'; import App from './App.vue'; import VueDOMPurifyHTML from 'vue-dompurify-html'; const app = createApp(App); app.use(VueDOMPurifyHTML, { default: { USE_PROFILES: { html: false }, }, }); app.mount('#app');...
vue-dompurify-html 是一个为 Vue.js 设计的安全 HTML 渲染替换组件,它基于 DOMPurify 库进行封装,用于过滤和处理 HTML 内容以防止跨站脚本攻击(XSS)。以下是关于 vue-dompurify-html 的详细使用指南: 1. 安装 vue-dompurify-html 包 首先,你需要在你的 Vue 项目中安装 vue-dompurify-html。你可以使用 npm 或...
npm install vue-dompurify-html@vue-legacy Usage importVuefrom'vue'importVueDOMPurifyHTMLfrom'vue-dompurify-html'Vue.use(VueDOMPurifyHTML)newVue({el:'#app',data:{rawHtml:'This should be red.'}}) In your template: You can also define yourDOMPurify configurations...
1.首先,您需要安装DOMPurify库。在命令行中运行以下命令: ``` npm install dompurify ``` 2.在需要使用DOMPurify的Vue组件中,导入DOMPurify库: ```vue import DOMPurify from 'dompurify'; ``` 3.在Vue组件中,您可以在需要净化HTML的地方使用DOMPurify,例如在模板中使用插值绑定: ```vue <template> </te...
vue-dompurify-html A "safe" replacement for thev-htmldirective. The HTML code is sanitized withDOMPurifybefore being interpreted. This is only a small wrapper around DOMPurify to ease its usage in a Vue app. You should take a look at theDOMPurify Security Goals & Threat Modelto understand wh...
一、引出vue-dompurify-html v-html可能引起跨站脚本攻击(Cross-Site Scripting 简称 XSS)。 所以,在网站上动态渲染任意 HTML 是非常危险的,因为容易导致 [XSS攻击]。只在可信内容上使用 v-html,永不用在用户提交的内容上。 仅用于展示的内容个人觉得可以使用。为了避免出现特殊情况,本文介绍一个插件“vue-dompurify...
vue-dompurify-html/types/index.d.ts Version: 403 BTypeScriptView Raw 1importtype{ Plugin }from'vue'; 2importtype{ DirectiveConfig, MinimalDOMPurifyConfig, DOMPurifyInstanceBuilder }from'./dompurify-html'; 3exporttype{ DirectiveConfig, MinimalDOMPurifyConfig, DOMPurifyInstanceBuilder, }; ...
vue-dompurify-html/LICENSE Version: 1.07 kBPlain TextView Raw 1 MIT License 2 3 Copyright (c) 2019-2022 Thomas Gerbet 4 5 Permission is hereby granted, free of charge, to any person obtaining a copy 6 of this software and associated documentation files (the "Software"), to deal...
Safe replacement for the v-html directive. Contribute to LeSuisse/vue-dompurify-html development by creating an account on GitHub.
import Vue from 'vue' import VueDOMPurifyHTML from 'vue-dompurify-html' Vue.use(VueDOMPurifyHTML, { namedConfigurations: { 'svg': { USE_PROFILES: { svg: true } }, 'mathml': { USE_PROFILES: { mathMl: true } }, } }); new Vue({ el: '#app', data: { rawHtml: 'This should ...