我在详细页面创建的方法
getCollect(){
// 将目前页面的内容放入storage中
const {
id,
currentIndex
} = this
wx.cloud.callFunction({
name: 'get_details_info',
data: {
id,
currentIndex
}
}).then(res => {
console.log(res);
this.collect = res.result.data
wx.setStorage({
key:'collect',
data: this.collect
})
//console.log(app.globalData.collect)
})
目前要在收藏页面读取collect对象却没法正常显示
<script>
const app = getApp()
export default {
name:"profileCollection",
data() {
return {
collect:{},
};
},
onShow() {
// 获取全局数组
const collect = wx.getStorageSync('collect')||[]
this.collect=collect
}
}
</script>
页面没法读出collect的内容(显示undefined)在组件中使用console.log也没法打印出对象
// 获取全局数组 const collect = wx.getStorageSync('collect')||[] //打印出来看看先 console.log(collect) this.setData({ collect:collect })