本文介绍了Vuejs v-model 特殊字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你能用 v-model 转义特殊字符吗?我在编辑从数据呼叫收到的文本时遇到问题.'this' 在编辑时在 textarea 中显示为 '&'#39;this'&#39'.我知道 v-html,但是你能在 v-model 中使用它吗?如果没有,还有什么选择?

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'&#39' in the textarea when editing. I know of v-html, but can you use that with v-model? If not, what is another option?

推荐答案

v-model 的工作方式类似于 v-text 并显示所有字符,而 v-html 让你显示 html 代码.如果您在源文件/调试器/响应中看到this",原因可能是编码或您尝试显示 json-text.因为 ' 是 NCR dez.对于字符 ' .

v-model works like v-text and shows all characters while v-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 提供自动双向绑定,如果您不需要,可以使用其他指令之一.

v-model gives automatic two way binding, if you do not need that you can use one of the other directives.

这篇关于Vuejs v-model 特殊字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 06:32
查看更多