Jsrender数据值在空白处中断



我正在使用jsrender,访问值时遇到问题

{{for items}}
<input type="text" id="id1" value="{{*: Json.stringify(data)}}" />
{{/for}}

这里我得到的值是:";{"id":"1","name":"johnny depp"};

$("#id1"(.val((给出'{'所有其他值的修剪和

<input type="text" id="id1" value={{*: Json.stringify(data)}} />

在这里我得到:";{id":"1","name":"johnny"depp"}

$("#id1"(.val((给出"{id":"1","name":"johnny">

空格被修剪后的单词如何显示全值

我已经尝试了<输入值={{:abc}}/>如果';abc';有空白,但仍不工作

由于从stringify()返回的字符串包含双引号",因此您需要在输入的标记上为value='...'使用单引号'

<input type="text" id="id1" value='{{*: JSON.stringify(data)}}' />

这将给出

<input type="text" id="id1" value='{"id":"1","name":"johnny depp"}' />

现在$("#id1").val()将给出:'{"id":"1","name":"johnny depp"}'

最新更新