一,目录结构
template是来存放模板的目录:
接下来我们直接看代码调用模板
module.wxml
<template name="modules">
<view wx:for='{{arr}}'>
{{item}}
</view>
</template>
index.wxml
<import src="../../template/module.wxml" /> //导入module模板
<view class='content'> //is='name'
<template is='modules' data="{{arr}}"></template>
</view>
index.js
Page({
data: {
arr:[1,2,3,4,5,6,7,8,9]
},
})
喜欢上方小程序,需要源码的,私信小编留下邮箱。