nutui icon indicating copy to clipboard operation
nutui copied to clipboard

chore(table): watch data add deep on true

Open yangjisen opened this issue 1 year ago • 3 comments

这个 PR 做了什么? (简要描述所做更改)

这个 PR 是什么类型? (至少选择一个)

  • [ ] feat: 新特性提交
  • [ ] fix: bug 修复
  • [ ] docs: 文档改进
  • [ ] style: 组件样式/交互改进
  • [ ] type: 类型定义更新
  • [ ] perf: 性能、包体积优化
  • [ ] refactor: 代码重构、代码风格优化
  • [ ] test: 测试用例
  • [ ] chore(deps): 依赖升级
  • [ ] chore(demo): 演示代码改进
  • [ ] chore(locale): 国际化改进
  • [x] chore: table组件data值增加深度监听

这个 PR 涉及以下平台:

  • [ ] NutUI H5 @nutui/nutui
  • [ ] NutUI Taro @nutui/nutui-taro

这个 PR 是否已自测:

yangjisen avatar Apr 11 '24 02:04 yangjisen

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 84.00%. Comparing base (2a1a4e5) to head (6da4fbc).

Additional details and impacted files
@@            Coverage Diff             @@
##               v4    #3026      +/-   ##
==========================================
- Coverage   84.05%   84.00%   -0.06%     
==========================================
  Files         216      216              
  Lines       23288    23289       +1     
  Branches     2521     2517       -4     
==========================================
- Hits        19575    19563      -12     
- Misses       3695     3708      +13     
  Partials       18       18              

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Apr 11 '24 02:04 codecov[bot]

这样修改是用于什么场景呢? Vue 本身支持了对数组操作的 Proxy,应该不需要添加 deep 🤔

eiinu avatar Apr 18 '24 01:04 eiinu

这样修改是用于什么场景呢? Vue 本身支持了对数组操作的 Proxy,应该不需要添加 deep 🤔

<nut-table :columns="columns" :data="items" striped />

当我修改 items里面的属性时, 表格不会自动更新,
或者当我重置 items 时, 数据不会更新

const handleAdd = () => {
state.items.push({
        uuid: uuid,
        name: state.formData.name,
        scope: parseInt(state.formData.scope),
        render: (recode) => {
          return h('button', {
            size: 'mini',
            plain: true,
            shape: 'round',
            onClick: () => state.items = state.items.filter(item => item?.uuid !== recode.uuid)
          }, '删除')
        }
      })
})

const handleReset = () => {
      state.items = []
    }

当我删除(handleReset)了后, 我再追加(handleAdd )的时候, 表格数据不会更新, 但是打印items是有相关的值

yangjisen avatar Apr 19 '24 09:04 yangjisen