Object.defineProperty(Array, "arr2tree", {
value(v = 0, k = 'pid', fk = 'id', c = 'children') {
return method.arr2tree(this, v, k, fk, c, true);
}
});
或
Array.prototype.arr2tree = function (v = 0, k = 'pid', fk = 'id', c = 'children') {
return method.arr2tree(this, v, k, fk, c, true);
};
- 发布:2021-03-04 16:07
- 更新:2022-09-21 11:14
- 阅读:825
产品分类: uniapp/App
PC开发环境操作系统: Windows
PC开发环境操作系统版本号: 19042.804
HBuilderX类型: 正式
HBuilderX版本号: 3.1.2
手机系统: Android
手机系统版本号: Android 10
手机厂商: OPPO
手机机型: k5
页面类型: vue
打包方式: 云端
项目创建方式: HBuilderX
示例代码:
操作步骤:
在使用数组时.引用方法arr2tree无效.提示 xxx.arr2tree is not a function
在使用数组时.引用方法arr2tree无效.提示 xxx.arr2tree is not a function
预期结果:
只要不是 xxx.arr2tree is not a function
只要不是 xxx.arr2tree is not a function
实际结果:
xxx.arr2tree is not a function
xxx.arr2tree is not a function
bug描述:
Object.defineProperty(Array, "arr2tree", {
value(v = 0, k = 'pid', fk = 'id', c = 'children') {
return method.arr2tree(this, v, k, fk, c, true);
}
});
与
Array.prototype.arr2tree = function (v = 0, k = 'pid', fk = 'id', c = 'children') {
return method.arr2tree(this, v, k, fk, c, true);
};
在使用数组时.引用方法arr2tree无效.提示 xxx.arr2tree is not a function
2 个回复
1***@qq.com
我在app上也是有问题的,在app上时添加在原型上的方法,vue实例中data的array无法使用, h5可以正常使用
承诺阳光
遇到了同样的问题,没人解决吗?
只有翅膀 (作者)
没办法了.只能通过class解决了.
2023-03-07 12:14