dcloudio / uni-ui

基于uni-app的、全端兼容的、高性能UI框架
https://uniapp.dcloud.io/component/uniui/uni-ui.html
Apache License 2.0
1.86k stars 665 forks source link

【bug】uni-swipe-action组件在钉钉小程序中的跨页面新增内容会报错 #903

Open cucuzi opened 3 months ago

cucuzi commented 3 months ago

版本信息

HbuilderX 4.15 uni-ui 1.5.0 uni-swipe-action 1.3.10 vue 2

代码片段

demo.vue

<template>
  <view>
    <button type="primary" @click="handleAdd">新增数据</button>
    <uni-swipe-action ref="swipeAction">
      <uni-swipe-action-item v-for="item in list" :key="item.id" :right-options="rightOptions"
        @click="handleDelete(item)">
        <view class="item-box" @click="handleClick(item)">
          <view>
            <text>{{ item.name }}</text>
          </view>
          <view class="item-box-subtitle">
            <text>选取日期:{{ item.date }}</text>
          </view>
        </view>
      </uni-swipe-action-item>
    </uni-swipe-action>
  </view>
</template>

<script>
  export default {
    data() {
      return {
        rightOptions: [{
          text: '删除',
          style: {
            backgroundColor: 'rgb(255,58,49)'
          }
        }],
        list: [],
      }
    },
    onLoad() {
      for (let i = 0; i < 3; i++) {
        this.list.push({
          id: i,
          name: `测试数据${i}`,
          date: "2024-06-05"
        })
      }
    },
    onShow() {},
    methods: {
      handleQuery(pageNum, isLoading) {},
      handleDelete(obj) {
        this.list.splice(this.list.findIndex(item => item.id === obj.id), 1)
      },
      handleClick(item) {
        uni.navigateTo({
          url: `/pages/demo/detail`,
          events: {
            refresh: () => {
              this.handleAdd()
            },
          },
          success: (res) => {
            res.eventChannel.emit('acceptDataFromOpenerPage', {
              item
            })
          }
        })
      },
      handleAdd() {
        let i = this.list.length
        let max = this.list.length + 3
        for (; i < max; i++) {
          this.list.push({
            id: i,
            name: `测试数据${i}`,
            date: "2024-06-05"
          })
        }
      }
    },
  }
</script>

<style lang="scss" scoped>
  .item-box {
    width: 100%;
    padding: 6px 4px;
    border-bottom: 1px solid rgba(0, 0, 0, .3);
    box-sizing: border-box;

    .item-box-subtitle {
      color: $uni-info;
    }
  }
</style>

detail.vue

<template>
  <view>
    <text>{{text}}</text>
    <button type="primary" @click="handleClick">新增数据</button>
  </view>
</template>

<script>
  export default {
    data() {
      return {
        text: ''
      }
    },
    onLoad() {
      this.getOpenerEventChannel().on('acceptDataFromOpenerPage', (data) => {
        this.text = data.item.name
      })
    },
    methods: {
      handleClick() {
        this.getOpenerEventChannel().emit("refresh")
      }
    },
  }
</script>

<style lang="scss" scoped>
</style>

复现步骤

https://github.com/dcloudio/uni-ui/assets/48954949/227f9e18-ff46-4fe6-b7c8-f54ecde87be0

GRCmade commented 1 week ago

你好,根据你的代码,没有复现你所说的问题,你可以提供更多的一些信息吗?

cucuzi commented 1 week ago

你好,根据你的代码,没有复现你所说的问题,你可以提供更多的一些信息吗?

您好,这是工程代码: https://github.com/cucuzi/uni-swipe-action-demo

GRCmade commented 1 week ago

具体该怎么操作才能复现?我这里划了半天也没报错 image

cucuzi commented 1 week ago

您好,您选择的是支付宝小程序,而不是钉钉小程序吧。 钉钉小程序控制台会输出dingtalk/SDKVersion image