我是靠谱客的博主 健康西牛,这篇文章主要介绍错误合集-Cannot both specify accessors and a value or writable attribute,,现在分享给大家,希望可以做个参考。
使用Object.defineProperty() 定义对象属性时,如已设置 set 或 get, 就不能设置 writable 和 value 中的任何一个了,不然会报如下错误:
TypeError: Invalid property descriptor. Cannot both specify accessors and a value or writable attribute, #<Object>
at Function.defineProperty (<anonymous>)
at Object.<anonymous> (/Users/mac/Documents/GitHub/the-red-book-note/双向绑定/test.js:2:8)
at Module._compile (internal/modules/cjs/loader.js:956:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)
at Module.load (internal/modules/cjs/loader.js:812:32)
at Function.Module._load (internal/modules/cjs/loader.js:724:14)
at Function.Module.runMain (internal/modules/cjs/loader.js:1025:10)
at internal/main/run_main_module.js:17:11
因为不再需要value和writable的属性了,所有关于value的操作都由get和set代理了。
最后
以上就是健康西牛最近收集整理的关于错误合集-Cannot both specify accessors and a value or writable attribute,的全部内容,更多相关错误合集-Cannot内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复