主页面index.html:
<script id="test" type="text/html">
{{each data as value index}}
<li>{{index}} - {{value.user}}</li>
{{/each}}
</script>
app.js:
require.config({
baseUrl: './js',
paths:{
"add": "./work/add",
'jquery': './lib/jquery-2.0.3.min',
'each': './work/each',
"text":'./lib/text',
'template':'./lib/template',
"math":'./app/math',
"api":"./app/api"
}
});
require(["add",'jquery','each','template','text!table.html','math',"api"],function(add,$,each,template,moban,math,api){
console.log(add.add(20,19));
console.log(each.each([1,2,3,4,5]));
console.log(moban);
$("#content").html(moban);
console.log(math.minus(20,9));
console.log(math.product(2,6));
api.getUser().then(function(user){
console.log(user)
});
var data = [
{
name: '张无忌'
},
{
name: '赵敏'
},
{
name: '谢逊'
},
{
name: '小昭'
},
];
var html = template('test', data);
document.getElementById('content').innerHTML = html;
});
文件路径如下:
请问下,为什么我在require.js 引入template.js 时,模板没有渲染出来,html为undefined?还有我现在可以做到引入html文件了,是不是也可以引入tpl文件呢?