我从服务器获取数据并循环数据值,然后根据数据添加HTML中的铆钉模板
这是我的代码
这是我的javascript代码
函数templateViewModel(属性){ this.modinfo= attributes.modAttr;console.log(this.modinfo) } rivets.binders.templatemod =函数(el,mod) { var element=document.createElement(mod.type);//示例mod.type = htitle element.setAttribute("mod-attr",JSON.stringify(mod)) el.parentNode && el.parentNode.appendChild(element) } rivets.components"htitle“={ template : function (){ new $api.html($api.dom("#h_title"));},初始化: function(el,attributes) {element),JSON.stringify(Mod)el.parentNode&&el.parentNode.appendChild(元素)}rivets.components(属性);Rivets.bind($api.dom(“#铆钉-绑定”),{not:not })
当我在chrome中运行它时,我发现已经创建了htitle标记,但是模板没有添加为什么?
这是chrome调试器中的代码
它应该是
{modinfo}
发布于 2017-09-05 02:32:54
我使用铆钉-包括来实现它
https://stackoverflow.com/questions/46021634
复制相似问题