收藏
回答

bind:tap使用动态事件名,页面跳转混乱?

点击文字跳转是对的,但是点击图片跳转混乱

本地调试,预览,真机调试均有这个问题

wxml

<!-- 分类按钮 -->
        <view class="typeButtonAll">
            <!-- 行循环 -->
            <view  class="typeButtonAllColumn">
            <block wx:for="{{productType}}" wx:for-item="item1" wx:for-index="index1">
                <!-- 列循环 -->
                <view class="typeButtonAllRow">
                <block wx:for="{{productType[index1]}}" wx:for-item="item2" wx:for-index="index2">
                    <!-- 外层 -->
                    <view class="typeButton" bind:tap="{{productTypeNameEng[index1][index2]}}">
                        <!-- 图片 -->
                        <image src="{{imgurl + item2}}" mode="aspectFit"></image>
                        <text style="margin-top: 10px; white-space: nowrap; font-size: 20rpx; font-weight: bold;">{{productTypeName[index1][index2]}}</text>
                    </view>
                </block>
                </view>
            </block>
            </view>
        </view>


js(以gas为例)

data: {
        imgurl: getApp().globalData.imgurl,
        productType: [['gas.png''electromagnetism.png''machine.png''cold.png''west.png'],
                        ['white.png''smoke.png''tableware.png''miscellaneous.png''other.png']],
        productTypeName: [['燃气设备''电磁设备''机械设备''制冷设备''西餐设备'],
                            ['白瓷设备''排烟设备''餐具''厨杂设备''其他']],
        productTypeNameEng: [['gas''electromagnetism''machine''cold''west'],
                                ['white''smoke''tableware''miscellaneous''other']]
    },
// 跳转燃气设备页面
    gas: function (params) {
        wx.navigateTo({
          url'./gas/gas',
        })

救救孩子

回答关注问题邀请回答
收藏

3 个回答

登录 后发表内容