- 需求的场景描述(希望解决的问题)
如下图,按雷磊老师的ORANGECAN项目实例,操作到文章详情页面跳转时详情面显示为空白,仔细检查核对代码,没找到问题,发现绑定POST-ID(文章ID)时,提示为12344,而书上为12345,实在找不到原因,求教各位老师、师兄弟姐妹,谢谢!
从WELCOME页面进入文章 列表正常,点击文章进入详情面时为空白,提示错误为
Cannot read property ‘data’ of undefined;at “pages/post/post-detail/post-detail” page lifeCycleMethod onLoad function
TypeError: Cannot read property ‘data’ of undefined
有类似情况的吗,请知道的指点一二,谢谢!
post-detail.wxml代码(抄书上的):
<view class=“container”>
<image class=“head-image” src="{{post.postImg}}"></image>
<text class=“title”>{{post.title}}</text>
<view class=“author-date”>
<view class=“author-box”>
<image class=“avatar” src="{{post.avatar}}"></image>
<text class=“author”>{{post.author}}</text>
</view>
<text class=“date”>{{post.dateTime}}</text>
</view>
<text class=“detail”>{{post.detail}}</text>
</view>
post.wxml代码:
<import src=“post-item/post-item-tpl.wxml”/>
<view>
<swiper indicator-dots=‘true’ autoplay=‘true’ interval=‘3000’>
<swiper-item>
<image src="/images/post/[email protected]"/>
</swiper-item>
<swiper-item>
<image src=’/images/post/[email protected]’/>
</swiper-item>
<swiper-item>
<image src=’/images/post/[email protected]’/>
</swiper-item>
</swiper>
<block wx:for="{{postList}}" wx:for-item=“item” wx:for_index=“idx”>
<view catchtap=“onTapToDetail” data-post-id="{{item.postId}}">
<template is=“postItemTpl” data="{{…item}}"/>
</view>
</block>
</view>
代码都是抄书上的