使用template模板渲染数据时报错:template not found

template模板渲染时报错:template not found。需要在js中加一句代码。

下面是我的代码,这段是模板的一个子循环:

<script id="orderList2" type="text/html">
       <ul>
	    {{each orderDetailList}}
		<li>
		    <a href="javascript:;" data-id="{{$value.skuId}}" class="order-img"><img src="{{$value.picUrl}}" alt="" /></a>
		    <div class="div-specal">
		    <strong class="order-detail order-detail-bold">
	            <span>{{$value.name}}</span>
		    </strong><br />
		    </div>
		    <div class="order-price price-{{$value.id}}"></div>
		    <div class="order-price sale-price-{{$value.id}}"></div>
		    <div class="order-price">{{$value.num}}</div>
		</li>
	{{/each}}
	</ul>
</script>

在模板中插入子循环:

<td colspan="4">
    {{include 'orderList2' $value}}
</td>

在js文件中加入:

$("body").append(orderList2);
function getAllOrder(URL,data) {
		var url = URL;
		var mData = data;
		config.request('get',url,mData,function(data){
			console.log(data);
			if (data.code == config.successCode) {
				var entity = data.entity;
				$("body").append(orderList2);
				var html = template("orderList", {
					'data': data
				});
				$("#orderListCon").html(html);
			} else {
				var tit = '获取数据失败!';
				config.message(obj,tit,time);
			}
		},function(e){
			var tit = '获取数据失败!';
			config.message(obj,tit,time);
		},'dd')
	}







版权声明:本文为qq_28143153原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。