假如我想点击一个列表中的子item跳转到另外一个界面
<import src="posts-item/posts-item-template.wxml" />
<view>
<block wx:for="{{posts_key}}" wx:for-item="item" wx:for-index="idx">
<template is="postItem" data="{{...item}}" catchtap="onPostTap"/>
</block>
</view>
我点击事件写在了template中,发现点击并没有效果,那么怎么解决呢,我们在template套一层view组件,把点击事件放在view组件上,
<import src="posts-item/posts-item-template.wxml" />
<view>
<block wx:for="{{posts_key}}" wx:for-item="item" wx:for-index="idx">
<view catchtap="onPostTap">
<template is="postItem" data="{{...item}}" />
</view>
</block>
</view>
这样点击就可以了.