Date.prototype.toJSON不允许重写
发布于 5 年前 作者 oluo 4196 次浏览 来自 问答

问题:  使用plugins后, 在手机上预览小程序时,报错:

[non-writer] write Date.prototype.toJSON is not allowed when using plugins at app.json

我的确重写了Date.ptototype.toJSON方法, 之前不使用plugins是正常的。这种情况应该怎么处理(想使用plugins时,并重写Date.prototype.toJSON方法)?

2 回复

en, 理解了, 同样的, 在2.0.9基础库中, 为了解决wx.request并发的限制, 通过以下代码重载了wx.request的实现

var wxRequest = wx.request;

Object.defineProperty(wx, “request”, { writable: true });

wx.request = function(){

//重写wx.request逻辑

}

不使用插件是正常的, 但如果使用插件, 报以下的错误:

sdk uncaught third Error 

 Cannot redefine property: request 

 TypeError: Cannot redefine property: request

请问, 这也是使用插件后安全性限制导致的吗? 如果是的话, 有没有解决办法?

你好,为了数据安全,在使用插件后我们确实增加了这个限制去禁止做原生对象的复写

回到顶部