参考小程序官方文档
https://developers.weixin.qq.com/miniprogram/dev/framework/view/wxml/template.html
//在pages 文件下新建一个template文件
//写好要引用的模板样式
**** 使用 name 属性,作为模板的名字。然后在<template/>内定义代码片段,如:
必须要添加 name 不然不知道你引用的是哪个模板
<template name="template">
<view>this is template</view>
</template>
//第二步在你需要引入的template 模板wxml文件里引入
<import src="/pages/template/template.wxml"/>
<block>
<view>
<template is="template" data="{{...item}}"/> //item 是导入的数据 然后直接去template 模板里去渲染
</view>
</block>
is 属性的名字必须和模板定义的名称一样
大概效果就是这样的