老师请问为什么dataset获取不到id
来源:19-1 从文章列表跳转到新闻详情页面(组件自定义属性及获取属性)
湘伦写立可白
2018-08-07
JS
onPost:function(e){
// event 是系统提供的事件对象
// currenTarget 是当前鼠标点击的组件
// dataset 是当前组件里的所有自定义属性
var postid = e.currenTarget.dataset.id;
wx.navigateTo({
url: 'detail/detail',
})
}wxml
<block wx:for="{{postkey}}" wx:for-item="item">
<view catchtap="onPost" data-id="{{item.postid}}">
<template is="postitems" data="{{...item}}"/>
</view>
</block>dataJS
var postcontents = [
{
post_toux: "/images/4.jpg",
post_name: "Ryan",
post_time: "2018-8-7",
post_title: "比利·林恩的战场故事",
post_banner: "/images/5.jpg",
post_con: "伊拉克战争时期,来自美国德州的19岁技术兵比利·林恩因为一段偶然拍摄的视频而家喻户晓。而林恩为了营救班长不惜铤而走险冲锋陷阵。",
post_pinl: "231",
post_zan: "728",
postid:0,
},
module.exports={
postkey : postcontents
}
写回答
1回答
-
7七月
2018-08-07
你把currentTarget打印出来看看id是怎么取的?
052018-08-08
相似问题