jdf2e / nutui

京东风格的移动端 Vue 组件库,支持多端小程序(A Vue.js UI Toolkit for Mobile Web)
https://nutui.jd.com
MIT License
6.12k stars 832 forks source link

chore(table): watch data add deep on true #3026

Open yangjisen opened 5 months ago

yangjisen commented 5 months ago

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

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

这个 PR 涉及以下平台:

这个 PR 是否已自测:

codecov[bot] commented 5 months ago

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 ```diff @@ 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.

eiinu commented 5 months ago

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

yangjisen commented 5 months ago

这样修改是用于什么场景呢? 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是有相关的值