Can you escape special characters with v-model? I am seeing an issue where I edit text that I receive from a data call. 'this' is showing as '&'#39;this''' in the textarea when editing. I know of v-html, but can you use that with v-model? If not, what is another option?
相关问题
- Axios OPTIONS instead of POST Request. Express Res
- Vue.js - set slot content programmatically
- Simple vue app doesn't show anything
- Getting Uncaught TypeError: …default is not a cons
- Vue.js computed property loses its reactivity when
相关文章
- Best way to dynamically change theme of my Vue.js
- vue-router how to persist navbar?
- How to Properly Use Vue Router beforeRouteEnter or
- Difference between nameFunction() {} and nameFunct
- Vue - best way to reuse methods
- setTimeout() not working called from vueJS method
- How to unbind an array copy in Vue.js
- Vue Cli 3 Local fonts not loading
v-model
works likev-text
and shows all characters whilev-html
let you show the html code. If you see "this" in you source file/debugger/response the reason might be the encoding or that you try to display json-text. Because'
is the NCR dez. for the character'
.v-model
gives automatic two way binding, if you do not need that you can use one of the other directives.The issue is that you have encoded text and you need to convert it to plain text. If it is proper HTML, one common trick is to set it as the
innerHTML
of a scratch div, and then extract thetextContent
from that div. I've created a little helper function in my snippet below to do that.The text you give looks like it has some extra quotes in it, so there may be some more massaging of the data that you need to do to unpollute it, but the approach is still what I show here: fetch the text, unpollute it, and assign the unpolluted text to the variable you want to edit.