javascript - 請問為啥這個不能渲染成功?
問題描述
<!DOCTYPE html><html lang='en'><head> <meta charset='UTF-8'> <title>Title</title></head><body><p id='content'></p><script src='http://www.aoyou183.cn/wenda/jquery-2.2.3.js'></script><script src='http://www.aoyou183.cn/wenda/template-web.js'></script><script src='http://www.aoyou183.cn/wenda/render.js'></script><script type='text/html'> <h1>{{title}}</h1> <ul>{{each list as value i}}<li>索引 {{i + 1}} :{{value}}</li>{{/each}} </ul></script><script> var data = {title: ’標(biāo)簽’,list: [’文藝’, ’博客’, ’攝影’, ’電影’, ’民謠’, ’旅行’, ’吉他’] }; var html = template.render(’test’, data); document.getElementById(’content’).innerHTML = html;</script></body></html>
問題解答
回答1:報的什么錯?type='text/html' 這是不是應(yīng)該是text/template,你的數(shù)據(jù)格式對嗎。
回答2:artTemplate里不需要什么render.js把另外最大的錯誤是這一句var html = template.render(’test’, data);應(yīng)該改為var html = template(’test’, data);
相關(guān)文章:
1. javascript - ionic1的插件如何遷移到ionic2的項目中2. java - 如何在Fragment中調(diào)用Activity的onNewIntent?3. javascript - h5上的手機(jī)號默認(rèn)沒有識別4. mysql里的大表用mycat做水平拆分,是不是要先手動分好,再配置mycat5. css - 關(guān)于input標(biāo)簽disabled問題6. python - 獲取到的數(shù)據(jù)生成新的mysql表7. 怎么用css截取字符?8. window下mysql中文亂碼怎么解決??9. javascript - jquery hide()方法無效10. python的文件讀寫問題?
