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

[Table] 重载 table 数据后修改数据元素的某个字段值时数据表不再更新 #3451

Closed
PDieE opened this issue Oct 10, 2023 · 3 comments

Comments

@PDieE
Copy link
Contributor

PDieE commented Oct 10, 2023

tdesign-vue-next 版本

1.5.7

重现链接

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

重现步骤

按照上述的重现链接,先点击状态列的 switch 此时 switch 会根据字段的新值表现为不同的开关状态
之后再点击重新加载数据按钮后 再点击 switch 则 switch 不会再根据字段的新值表现为不同的开关状态

期望结果

希望能像重新加载前一样正确应用更改

实际结果

No response

框架版本

No response

浏览器版本

No response

系统版本

No response

Node版本

No response

补充说明

No response

@github-actions
Copy link
Contributor

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

@github-actions
Copy link
Contributor

github-actions bot commented Oct 10, 2023

♥️ 有劳 @Louiszhai @PengYYYYY @chaishi 尽快确认问题。
确认有效后将下一步计划和可能需要的时间回复给 @PDieE

@chaishi
Copy link
Collaborator

chaishi commented Oct 15, 2023

提供的代码用法:

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

const changeStatus = (data) => {
  data.onChangeStatus = true;
  setTimeout(() => {
    data.status = data.status === 1 ? 0 : 1;
    data.onChangeStatus = false;
  }, 1000);
};
企业微信截图_ee3c001a-cc15-4846-8e38-3e1db8d384e6

这种用法在使用的时候,Vue 的参数 data 无法正常动态更新,组件就无法收到新的值。建议再确认下 Vue Props 属性更新的使用方法。

下方为建议代码用法,无论是否修改过数据,Switch 状态变化都表现正常

完整示例代码地址:https://stackblitz.com/edit/9u8uyp-bfkc1x?file=src%2Fdemo.vue

const changeStatus = (row, rowIndex) => {
  const loadingData = { ...row };
  loadingData.onChangeStatus = true;
  data.value[rowIndex] = loadingData;
  setTimeout(() => {
    const newData = { ...row };
    newData.status = row.status === 1 ? 0 : 1;
    newData.onChangeStatus = false;
    data.value[rowIndex] = newData;
  }, 1000);
};

@chaishi chaishi closed this as completed Oct 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants