<script>
function isHave(str,text){
if(text.indexOf(str) != -1){
return TRUE;
}
return FALSE;
}
</script>
这是一个判断函数 判断已知文字中是否存在指定的字符串,我想这样用
<script id="tpl" type="text/html">
{{each datas data}}
{{if isHave('赵',data.name)}}//如果存在指定的字符串,就有输出,**这种判断到底怎么写**
{{data.name}}
{{/if}}
{{/each}}
</script>
datas.map(data=>isHave('赵',data.name)?
'有的话你要干嘛':'没有的话你要干嘛')