Created
September 26, 2021 08:23
-
-
Save hahuaz/90caa838f47e4fc71e00ea0681addbb4 to your computer and use it in GitHub Desktop.
edit typo in vue
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
<template> | |
<div class="text__container"> | |
<label for="text">put text:</label> | |
<textarea | |
id="" | |
v-model="text" | |
name="texts" | |
cols="30" | |
rows="10" | |
style="border: 1px solid black" | |
@input="correctIt" | |
> | |
</textarea> | |
</div> | |
</template> | |
<script> | |
export default { | |
data() { | |
return { | |
text: null, | |
correctedTest: null, | |
corrections: { | |
realy: 'really', | |
wierd: 'weird', | |
}, | |
} | |
}, | |
methods: { | |
correctIt() { | |
const entries = Object.entries(this.corrections) | |
entries.forEach((entry) => { | |
if (this.text.includes(entry[0])) { | |
this.text = this.text.replace(entry[0], entry[1]) | |
} | |
}) | |
}, | |
}, | |
} | |
</script> | |
<style lang="scss" scoped> | |
.text__container { | |
background-color: red; | |
} | |
</style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment