// test.js 页面数据
Page({
data: {
test: {
aaa: 1,
bb: [{
id: 1,
name: ‘qiushi’
},{
id:2,
name: ‘siteng’
}]
}
}
})
// test.wxml 引用模版
<import src=“parent.wxml” />
<template is=“test” data="{{…test}}" />
// parent.wxml
<template name=“test”>
{{aaa}}
<include src=“item.wxml” />
</template>
// item.wxml
<view>
{{aaa}}
<block wx:for="{{bb}}">
{{item.name}},
{{aaa}} // 最后在结果中引用不到aaa
</block>
</view>
结果:
1
1 qiushi,siteng,
最后在结果中引用不到aaa