Skip to content

Commit

Permalink
feat: demo add clear text
Browse files Browse the repository at this point in the history
  • Loading branch information
Shimada666 committed Sep 17, 2021
1 parent c8544d9 commit b2f9091
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
<a-form-item>
<a-button type="link" @click="resetText">重置文本(reset text)</a-button>
</a-form-item>
<a-form-item>
<a-button type="link" @click="clearText">清空文本(clear text)</a-button>
</a-form-item>
</a-form>
<code-diff
:old-string="oldString"
Expand Down Expand Up @@ -98,6 +101,12 @@ export default defineComponent({
oldString.value = oldShortText.value
newString.value = newShortText.value
}
const clearText = () => {
localStorage.removeItem('oldString')
localStorage.removeItem('newString')
oldString.value = ''
newString.value = ''
}
watch(oldString, () => localStorage.setItem('oldString', oldString.value))
watch(newString, () => localStorage.setItem('newString', newString.value))
return {
Expand All @@ -106,7 +115,8 @@ export default defineComponent({
newString,
renderStart,
renderEnd,
resetText
resetText,
clearText
}
}
})
Expand Down

0 comments on commit b2f9091

Please sign in to comment.