javascript - 无法在 Next.js 中声明 Object.prototype
问题描述
我正在尝试为 Next.js 中的对象创建自定义函数
我正在写以下内容
Object.prototype._something = function (something) {
console.log(something)
}
它有效,但现在它给了我一个奇怪的错误
Warning: Invalid value for prop `_something` on <img> tag. Either remove it from the element, or pass a string or number value to keep it in the DOM.
但它只适用于 Object.prototype,如果我声明与 Array.prototype 相同的函数,一切正常
解决方案
推荐阅读
- c++ - 使用 OpenCV 映射 OpenGL
- templates - 如何从odoo中的取消链接按钮更改文本?
- azure-analysis-services - Azure Analysis Services 从本地 Oracle 数据库部署模型
- java - 主应用程序线程在到达方法结束之前不会更新 GUI
- reactjs - 有没有办法在 react-bootstrap 中使用引导类?
- bazel - 如何编写适用于外部存储库的 Bazel 规则?
- vue.js - 有一种方法可以验证小吃店只打开一次吗?
- for-loop - Verilog - 是否可以根据生成块中的 genvar 变量为寄存器分配值
- logstash - 我无法在 logstash 中为 activamq 日志创建 grok 模式
- c# - 如何使用 C# 使用相同的 SQL Server 连接运行 foreach 循环