[Wondgirl] 微信小程序(三)模板的使用

来源:互联网 发布:淘宝客服周总结计划 编辑:程序博客网 时间:2024/06/05 15:58

在上篇文章的基础上,我们新建一个模版目录templates,
在里面创建一个头部模板header.wxml和一个底部模板footer.wxml.

这里写图片描述

header.wxml:

<text>头部</text>

footer.wxml:

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

在first.wxml里引用头部模板

<include src="../templates/header"/>

在first.wxml里引用底部模板

<import src="../templates/footer" /><template is="footer1" data="{{text:'导入设置的内容...'}}"/>

运行结果如下:
这里写图片描述

1 0
原创粉丝点击