mirror of
https://github.com/CorentinTh/it-tools.git
synced 2024-11-16 06:04:50 +08:00
refactor(json-viewer): add clear button
This commit is contained in:
parent
3aefe83a31
commit
048bc4ae94
1 changed files with 15 additions and 2 deletions
|
@ -5,8 +5,21 @@
|
||||||
:feedback="rawJsonValidation.message"
|
:feedback="rawJsonValidation.message"
|
||||||
:validation-status="rawJsonValidation.status"
|
:validation-status="rawJsonValidation.status"
|
||||||
>
|
>
|
||||||
<n-input v-model:value="rawJson" class="json-input" type="textarea" placeholder="Paste your raw json here..." />
|
<n-input
|
||||||
|
v-model:value="rawJson"
|
||||||
|
class="json-input"
|
||||||
|
type="textarea"
|
||||||
|
placeholder="Paste your raw json here..."
|
||||||
|
autocomplete="off"
|
||||||
|
autocorrect="off"
|
||||||
|
autocapitalize="off"
|
||||||
|
spellcheck="false"
|
||||||
|
/>
|
||||||
</n-form-item>
|
</n-form-item>
|
||||||
|
|
||||||
|
<n-space justify="center">
|
||||||
|
<n-button secondary @click="rawJson = ''">Clear</n-button>
|
||||||
|
</n-space>
|
||||||
</n-card>
|
</n-card>
|
||||||
|
|
||||||
<n-card v-if="cleanJson.length > 0">
|
<n-card v-if="cleanJson.length > 0">
|
||||||
|
@ -39,7 +52,7 @@ const rawJsonValidation = useValidation({
|
||||||
source: rawJson,
|
source: rawJson,
|
||||||
rules: [
|
rules: [
|
||||||
{
|
{
|
||||||
validator: (v) => JSON.parse(v),
|
validator: (v) => v === '' || JSON.parse(v),
|
||||||
message: 'Invalid json string',
|
message: 'Invalid json string',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
Loading…
Reference in a new issue