首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >为什么我setdata中的数组p1前端没显示?

为什么我setdata中的数组p1前端没显示?

提问于 2019-05-12 15:59:20
回答 0关注 0查看 186

const db = wx.cloud.database({});

const cont = db.collection(' hero');

Page({

/**

* 页面的初始数据

*/

data: {

p: [],

p1: []

},

/**

* 生命周期函数--监听页面加载

*/

onLoad: function (options) {

db.collection('hero').get({

success: res => {

this.setData({

p: res.data

})

// console.log(res.data[0].herotype)

// var pp = this.data.p

// const length = pp.length

var id = parseInt(options.role)

console.log(id)

for(let i=0;i<=res.data.length;i++){

// console.log(res.data.length)

if(id==res.data[i].herotype){

this.setData({

p1: res.data[i]

})

}

}

}

}) }

<view class='big'>

<view class='list' wx:for="{{p1}}">

<image class='list-img' src='{{item.img}}'></image>

<view class='pro-body'>

<view class='list-item1'>{{item.ename}}</view>

<view class='list-item1'>{{item.name}}</view>

</view>

</view>

</view>

回答

和开发者交流更多问题细节吧,去 写回答
相关文章

相似问题

相关问答用户
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档