-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: add i18nHtml & set-global-options usage
- Loading branch information
Showing
2 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
32
packages/docs/content/2.documentation/4.set-global-options.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
|
||
``` |