您的位置:首页 > 移动开发 > 微信开发

WeChat小程序学习心得——模板使用

2017-11-14 15:43 204 查看
在footer.wxml下编写两个模板

<template name="footer1">这是底部1 - {{text}}</template>
<template name="footer2">这是底部2 - {{text}}</template>

导入模板

在需要导入footer.wxml中两个模板的wxml界面,使用import导入footer.wxml文件

<import src="../templates/footer"/>
然后选取指定的模板,并可用data=""对模板中的数据进行动态修改

<template is="footer1" data="{{text:'导入设置的内容'}}"/>
本例使用footer1模板,并对其text赋值

值得注意的是:如果在footer.wxml导入有另一模板temDemo.wxml,则其它页面(如 index.wxml)在导入footer.wxml时,无法将temDemo.wxml一并导入

具体代码可见我上传的资源 WeChat小程序数据渲染和模板使用
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息