自定义组件 bingtap事件 自定义值没传过去?
发布于 6 年前 作者 weihe 10046 次浏览 来自 官方Issues

这是自定义组件

<view class=“cu-custom” style=“height:{{CustomBar}}px”>

<view class=“cu-bar fixed {{bgImage!=’’?‘none-bg text-white bg-img’:’’}} {{bgColor}}” style=“height:{{CustomBar}}px;padding-top:{{StatusBar}}px;{{bgImage?‘background-image:url(’ + bgImage+’)’:’’}}”>

<view class=“action” bindtap=“BackPage” wx:if="{{isBack}}">

<text class=“cuIcon-back”></text>

<slot name=“backText”></slot>

</view>

<view class=“action border-custom”  wx:if="{{isCustom}}" style=“width:{{Custom.width}}px;height:{{Custom.height}}px;margin-left:calc(750rpx - {{Custom.right}}px)”>

<text class=“cuIcon-back” bindtap=“BackPage”></text>

<text class=“cuIcon-homefill” bindtap=“toHome”></text>

</view>

<view class=“content” style=“top:{{StatusBar}}px”>

<slot name=“content”></slot>

</view>

<slot name=“right”></slot>

</view>

</view>

这个是这个

BackPage(e) {

console.log(“返回事件1”,e);

var url=e.currentTarget.dataset.url;

console.log(url);

if(url==null){

wx.navigateBack({

delta: 1

});

}else{

wx.navigateBack({

url: url

});

}

},

<cu-custom bgColor=“bg-gradual-blue” data-url=’…/list/list’ isBack="{{true}}">

<view slot=“backText” data-url=’…/list/list’>返回</view>

<view slot=“content”>工单处理</view>

</cu-custom>

这个data-url 怎么没有传过去 ,该怎么传呢

2 回复

没有绑定url怎么能接收到

<cu-custom data-url>是父组件将url传给自定义组件。BackPage这个事件是自定义组件中的事件吗?如果是的话,你自定义组件中使用BackPage时没有传入url参数,事件中的e.currentTarget.dataset.url是得不到的。

回到顶部