加急!!!preview组件点击后跳转空白
来源:16-9 自定义分享button

慕移动7441361
2019-10-22
1.preview.wxml
<view catch:tap="onTap" class="container">
....
</view>
2.preview的index.js
// components/preview/index.js
Component({
methods: {
onTap:function(event){
this.triggerEvent('tapping',{
cid:this.properties.classic.id,
type:this.properties.classic.type
},{})
}
}
})
3.my.wxml
<view class="container">
....
<v-preview bind:tapping="onJumpToDetail" class="preview" classic="{{item}}" />
</view>
4.my.js
onJumpToDetail(event){
const cid = event.detail.cid
const type = event.detail.type
// console.log(cid)
wx.navigateTo({
url:`/pages/classic-detail/classic-detail?cid=${cid}&type=${type}`
})
}
5.classic-detail.js
data: {
cid:0,
type:100
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.data.cid = options.cid
this.data.type = options.type
},
6.classic-detail.wxml
<v-classic cid="{{cid}}" type="{{type}}" />
7.classic.js
onShow: function () {
console.log(this.properties.type)
//判断是不是带参数跳转过来的
const cid = this.properties.cid
const type = this.properties.type
if (!cid) {
classicModel.getLatest((res) => {
this.setData({
classic: res,
likeCount: res.fav_nums,
likeStatus: res.like_status
})
})
}else{
classicModel.getById(cid, type,res=>{
console.log(res)
this._getLikeStatus(res.id, res.type)
this.setData({
classic: res,
latest: classicModel.isLatest(res.index),
first: classicModel.isFirst(res.index)
})
})
}
},
在** 我的 ** 页面点击preview卡片时跳转,显示不出内容
写回答
1回答
-
7七月
2019-10-22
显示不出内容,需要自己排查下,这个要调试的,在这一大段代码里找问题是不现实的。可能是因为wxml里解析的时候层次不对,这个原因出现的最多。
052019-10-22
相似问题