我有这样的 JSON:
{ "something": "http://something.com" }
和这样的 HTML:
<a href="{{something}}">{{something}}</a>
当我应用 Mustache 时,我得到了
<a href="%7B%7Bsomething%7D%7D">http://something.com</a>
但我想得到的是
<a href="http://something.com">http://something.com</a>
我已经尝试过{{{ something}}}
、{{& something}}
、单引号、双引号……我什至阅读了文档。
你能帮帮我吗?
最佳答案
我认为您需要使用 &
结合使用模板脚本围绕您的模板进行转义:
<script type="text/template" id="tmpl">
<a href="{{& something }}">{{ something }}</a>
</script>
找到这个例子 over here .
关于javascript - href 里面的 mustache ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11218075/