Skip to content
mt-v-safe-html
GitHub

$safeHtml

Sometimes, we need to update globalOptions, we provide setGlobalOptions to override and update options.

Type

type Options = {
  defaultString?: string
  sanitizeConfig?: SanitizeConfig
}

Usage

<template>
  <div v-html="$safeHtml(inValidHtmlString)"></div>
  <button @click="handleClickChange">change options</button>
</template>

<script setup lang="ts">
  import { ref } from 'vue'
  import { setGlobalOptions } from 'mt-v-safe-html'

  const inValidHtmlString = ref(`
    <div></div>invalid div</div>
`)

  const handleClickChange = () => {
    setGlobalOptions({ defaultString: 'new default string' })
  }
</script>