index.wxml
<!--index.wxml-->
<view class="container">
<block wx:if="{{userId==123}}">
<view wx:for="{{array}}" wx:for-item="item" wx:key="index">
<text id="message-{{index}}">{{index}} - {{item.message}}</text>
</view>
</block>
</view>
index.js
//index.js
//获取应用实例
const app = getApp()
Page({
data: {
motto: 'Hello World1',
userId: '123',
show:false,
array:[{
message: 'hello'
},
{
message: 'world'
},
{
message: '!'
},
]
},
onLoad: function () {
},
onShow: function(){
// app.globalData.userInfo="wxopen.club";
}
})