Extjs存储区剪切bigint值的最后一位



我使用Extjs 7.4。当我将数据加载到extjs存储区时,我会遇到bigint值的最后一位数字被截断的问题。模型字段类型是int还是number都无关紧要。Bigint值​​只有当类型为字符串时才正确显示。我不能将该字段用作数据模型的idProperty中的字符串。有人知道吗。

也许这是javascript的限制,而不是ExtJs。事实上,如果你试图创建一个具有bigint属性的新对象,你会得到一些截断的数字:

var record = {
numericValue: 9223372036854776807,
stringValue: "9223372036854775807"
};
console.log(record);

它打印:

{
numericValue: 9223372036854776000,
stringValue: "9223372036854775807"
}

---编辑---

一个解决方案可以是传递商店模型中定义的BigInt字段的转换配置。请注意,存储最初应该将您的属性作为字符串读取。这样做,属性将正确存储BigInt值:

Ext.define("MyStore",{
extend: "Ext.data.Store",
fields: [
{
name: "bigIntProp",
convert: function (value) {
return BigInt(value);
}
}
]
});
var store = new MyStore();
store.add({ bigIntProp: '9223372036854775807' });
// This correctly print the big int value now
console.log(store.getAt(0).get("bigIntProp"));

最新更新