微信小程序在用到template 模板的时候,引入了wxml ,wxss ,但是在引入js的时候出了问题,具体情况如下:
在template.wxml 里面定义模板:
<template name = "msgItem">
<view class='hospList' wx:for="{{hospListArray}}">
<view class='hospImage'><image src='{{item.imageSrc}}'></image> </view>
<view class='hospRight'>
<view class='rightFirstLine'>
<view class='hospTitle'>{{item.hospName}}</view>
<view class='hospLevel'>{{item.hospLevel}}</view>
</view>
<view class='RightSecond '>
<text>{{item.hospAdress}}</text>
</view>
<view class='RightSecond'>
<text class='survey'>{{item.hospSurvey}}</text>
</view>
</view>
</view>
</template>
然后在index.wxml里引用:
<import src="../template/template.wxml"/>
<template is="msgItem" data="{{...item}}"/>
在index.wxss里也相应的引用:
@import "/template/template.wxss";
但是由于template.js未引用过来,数据绑定不能渲染出来。恳求大神指点,js该如何引用。不慎感激。
文件结构是这样的: