Open jacktang opened 3 years ago
useEffect 需要加入对columns的重新渲染?
更新到最新版试试?最新版应该解决了这个bug
🙅 编译失败.
./node_modules/taro3-table/build/Table/Table.js
Module not found: Can't resolve 'D:/Repos/taro3-table/node_modules/@babel/runtime/helpers/esm/defineProperty'
写了绝对路径了,我这边没有 D:/
打包的build结果里面带入了下面的信息
import _objectSpread from "D:/Repos/taro3-table/node_modules/@babel/runtime/helpers/esm/objectSpread2";
import _defineProperty from "D:/Repos/taro3-table/node_modules/@babel/runtime/helpers/esm/defineProperty";
import _toConsumableArray from "D:/Repos/taro3-table/node_modules/@babel/runtime/helpers/esm/toConsumableArray";
import _typeof from "D:/Repos/taro3-table/node_modules/@babel/runtime/helpers/esm/typeof";
import _slicedToArray from "D:/Repos/taro3-table/node_modules/@babel/runtime/helpers/esm/slicedToArray";
var _this = this;
1.0.17 版本也是不行的,useEffect没加入 columns.... 不会触发render() 的 看了代码 useEffect加入了 columns,但是还是没效果,不知道例子代码应该是怎样的
useEffect(() => {
setColumns(pColumns); // *
if (pColumns.some((i: AnyOpt) => {
return !['number', 'undefined'].includes(typeof i.width);
})) {
console.error('[taro3-table] -', '列配置 width 参数类型需为 number');
setError(true);
}
}, [columns, pColumns]); //*
注释带 //*
是fix bug的地方
因为后面render里面使用的是columns
, 所以需要set一下。另外传入的参数是 pColumns
初始化定义列表头之后,动态生成重新render不能把列表头设置进去,对应数据也显示不出来