Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
cucuzi opened this issue Jun 5, 2024 · 4 comments · May be fixed by #904
Open

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

cucuzi opened this issue Jun 5, 2024 · 4 comments · May be fixed by #904

Comments

@cucuzi
Copy link

cucuzi commented Jun 5, 2024

版本信息

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>

复现步骤

QQ202465-132619.mp4
@cucuzi cucuzi changed the title 【bug】uni-swipe-action-item组件的在钉钉小程序中的跨页面新增实例时会报错 【bug】uni-swipe-action组件在钉钉小程序中的跨页面新增内容会报错 Jun 5, 2024
@GRCmade
Copy link
Contributor

GRCmade commented Aug 29, 2024

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

@cucuzi
Copy link
Author

cucuzi commented Aug 30, 2024

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

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

@GRCmade
Copy link
Contributor

GRCmade commented Aug 30, 2024

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

@cucuzi
Copy link
Author

cucuzi commented Aug 30, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants