Skip to content

Commit

Permalink
docs: add i18nHtml & set-global-options usage
Browse files Browse the repository at this point in the history
  • Loading branch information
motea927 committed Jun 18, 2023
1 parent 60833b4 commit 51e9787
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/docs/content/2.documentation/3.i18nHtml.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# $i18nHtml
`$i18nHtml` is an syntax sugar for use, just use like `$t`, make sure you already install [vue-i18n](https://vue-i18n.intlify.dev/).

## string input
Basic usage, use i18n key as parameter.

```vue
<template>
<div v-html="$i18nHtml('some-key')"></div>
</template>
```
32 changes: 32 additions & 0 deletions packages/docs/content/2.documentation/4.set-global-options.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# setGlobalOptions
Sometimes, we need to update globalOptions, we provide `setGlobalOptions` to override and update options.

## Type
```ts
type Options = {
defaultString?: string
sanitizeConfig?: SanitizeConfig
}
```
## Usage
```vue
<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>

```

0 comments on commit 51e9787

Please sign in to comment.