dojo模板字符串最佳实践
之前写了一篇文章介绍dojo/string模块提供的模板处理函数substitute ,随之而来的一个问题是写模板字符串太麻烦了,涉及到转义等问题。 <div class="content"> 假设template.html放在templates子目录中,那么使用方法如下: require(["dojo/dom","dojo/string","dojo/text!./templates/template.html"],function(dom,string,template){var article = {title : "",detail : "",info : ""};dom.byId("dom-id").innerHTML = string.substitute(template,article);}); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |