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

[cell] cell组件中click传参数未更新 #1246

Open
LoopZhou opened this issue Mar 4, 2024 · 4 comments
Open

[cell] cell组件中click传参数未更新 #1246

LoopZhou opened this issue Mar 4, 2024 · 4 comments
Labels
question Further information is requested

Comments

@LoopZhou
Copy link
Collaborator

LoopZhou commented Mar 4, 2024

tdesign-mobile-vue 版本

1.1.0

重现链接

https://stackblitz.com/edit/gk4j3n-9ypxb5?file=src%2Fdemo.vue

重现步骤

参考重现示例中,testLog方法打印index, 当删除dataArr中一个数据中, cell的index未更新, tag组件正常更新

2024-03-04.12.38.35.mov

期望结果

cell组件click方法中参数更新

实际结果

cell组件click方法中参数未更新

框架版本

Vue(3.2.0)

浏览器版本

Chrome(117.0.5938.149)

系统版本

MacOS

Node版本

16.17.0

补充说明

No response

Copy link
Contributor

github-actions bot commented Mar 4, 2024

👋 @LoopZhou,感谢给 TDesign 提出了 issue。
请根据 issue 模版确保背景信息的完善,我们将调查并尽快回复你。

@XBIsland
Copy link
Contributor

XBIsland commented Mar 5, 2024

tag 也有这个问题,看源码大概有 12 个组件有这个问题,全局搜下关键字 props.onClick 可以找到,将源码改为 context.emit 的方式也许可以修复。

临时解决可以通过将 key 绑定在 t-<name> 上解决。

<div v-for="(item, index) in list">
  <t-cell
    :key="item.name"
    :title="item.name"
    @click="testLog(index)"
  ></t-cell>
</div>

@catiwang
Copy link
Contributor

catiwang commented Mar 8, 2024

 <div v-for="(item, index) in dataArr" :key="item.name">
    <t-cell note="辅助信息" @click="testLog(index)">
      <template #title>
        {{ item.name }}
      </template>
    </t-cell>
  </div>

自测过这样写就可以更新了,tag如果像之前cell这样的写法,用:content="item.name",也会更新不了,个人认为可以换成这种写法
@LoopZhou

@XBIsland
Copy link
Contributor

我尝试排查原因,最终发现跟 emits 声明和 props 定义有关。
应该跟组件本身无关,更多可能是 Vue 的写法有关,个人觉得是个值得讨论的问题。

emits👉: https://cn.vuejs.org/api/options-state.html#emits
demo👉: https://stackblitz.com/edit/vitejs-vite-z7hfy7?file=src%2FApp.vue

我会尝试提交 PR 修复这个问题。

@anlyyao anlyyao added the question Further information is requested label Mar 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants