vue html data,javascript - Vuejs: V-HTML data binding of html data against eslint rule - Stack Overf...

As stated in the other answer, you can disable the warning but a good practice is to make sure the rule is rightfully disabled.

To do so, you can use dompurify that will parse the HTML you are giving to the browser, remove any malicious part and display it safely.

The issue is still there but you can use RisXSS which is an ESLint plugin that will warn the uses of v-html if you do not sanitize it before (in a sense, this is an improved version of vue/no-v-html ESLint rule).

To do so, install dompurify and eslint-plugin-risxss:

npm install dompurify eslint-plugin-risxss

Add risxss to your ESLint plugins then use DOMPurify:

id="foreignerBtn"

class="tabButton"

@click="foreignerClick"

v-html="sanitizedTextContent2"

>

id="foreignerBtn"

class="tabButton"

@click="foreignerClick"

v-html="textContent2"

>

import DOMPurify from 'dompurify';

export default {

data () {

return {

sanitizedTextContent2: DOMPurify.sanitize(textContent2)

}

}

}

Disclaimer: I am a contributor of RisXSS plugin.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值