Taro: 某些情况下对 onClick={this.XXXX.bind(this)} 编译不太友善

Created on 28 Jul 2018  ·  3Comments  ·  Source: NervJS/taro

<Checkbox value="1" checked={value.active == 1 ? true : false} onClick={this.handleCheckoutCartSelectone.bind(this, value)} />
   <view class="cart-item" wx:for="{{loopArray0}}" wx:for-item="value" wx:for-index="key">
                <checkbox value="1" checked="{{value.active == 1 ? true : false}}" bindtap="handleCheckoutCartSelectone"
                data-e-handleCheckoutCartSelectone-so="this" data-e-handleCheckoutCartSelectone-a-a="{{value}}"
                data-component-path="{{$path}}"></checkbox>
                <view class="image">
                    <image src="{{value.img_url}}" />
                </view>
                <view class="cart-info">
                    <view class="name">{{value.name}}</view>
                    <view class="name">{{value.$loopState__temp3}}</view>
                    <view class="name">¥{{value.base_product_price}}</view>
                    <view class="cart-input">
                        <view class="btn cartLess">-</view>
                        <input class="weui-input" type="text" value="{{value.qty}}" maxlength="10"
                        />
                        <view class="btn cartAdd">+</view>
                    </view>
                </view>
            </view>

Most helpful comment

anu的React转小程序已经实现传复杂对象了。

image

image
image
将参数放在wxml是不明智的,这样会导致体积变大。可以通过UUID指用在虚拟DOM中绑定好的事件

https://github.com/RubyLouvre/anu/tree/master/packages/render/miniapp

All 3 comments

恩,目前 bind 传参只能通过将参数附在 wxml 的属性上来进行传参,所以只能编译成这样了

anu的React转小程序已经实现传复杂对象了。

image

image
image
将参数放在wxml是不明智的,这样会导致体积变大。可以通过UUID指用在虚拟DOM中绑定好的事件

https://github.com/RubyLouvre/anu/tree/master/packages/render/miniapp

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings