问题标签 [defineproperty]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
xml - 如何在 Soley Studio 的图形视图中使用图像而不是形状作为节点?
我正在 Soley Studio 中设置我的图形视图模板。在一些预装的解决方案中,我看到图形视图中的节点已经用图标或图形而不是圆形、矩形等来可视化。
我想以这样的方式为节点类定义我的属性,它显示一个齿轮图标或类似的东西。我必须使用哪个<property>
?
我从另一个解决方案复制了一个,但它没有改变任何东西:
我想用<Property Name="Image"> <Value IsReference="true">icon</Value></Property>
. 但没有任何改变。如何引用我想要的“图标”?将其添加到图像文件夹没有帮助。
javascript - How can I define a property on the tab's main window object?
I'm trying to define the property jQuery
on the window
object from a content script with code in the setter. That way, when the actual jQuery object is defined, I can use it right away. I seem to be unable to get it right, though.
The target website is Outlook.com. That's the webmail version of Outlook.
I tried to put the code in the content script directly, but even if I put "all_frames": true
in the content_scripts
section of the manifest (so the code gets injected into every frame), it isn't working.
I verified that window.jQuery
is properly defined afterwards by the actual jQuery
function/object, but my setter code is never executed.
I also tried it with message passing: I send a message with the code as a string to a background script, and use executeScript
to execute it on the correct tab, but this also doesn't work.
And in my background script:
If I put something else than the Object.defineProperty
code in the executeScript
code, that works fine. I only have problems defining the property.
reactjs - 如何在 IE8 中转换 Object.defineProperty
我使用 React、Webpack、Babel 构建项目并希望它在 IE8 中运行,存在 IE8 不支持 Object.defineProperty 的问题。
我没有使用这个功能,但是 npm 包可以做到,比如 react-router。我已经尝试过 polyfill、es5-shim、es5-sham 和很多 babel 插件,但不幸的是不适合我......
那么对于这种情况我还能做些什么呢?
真心欣赏。
javascript - 日期作为构造函数和函数
我怎么知道 Date 何时被称为构造函数(使用“new”),何时被称为函数?
更新
这些答案不适用于这种情况。
this
总是等于一个window
javascript - 对象为 getter 和 setter 定义属性
我收到有关此代码的最大调用堆栈大小的错误。
错误
javascript - 从外部更新 JS 定义属性
我使用下面的代码,我想从其他模块更新一些属性,我应该怎么做?
这是模块代码(实际上还有更多属性...)
现在我从其他模块需要它,我想将键 USER_PATH 更新为“newValue”。
我尝试要求此模块并执行以下操作,它不会更改 USER_PATH 中的值,在调试器中我看到“oldValue”
javascript - Object.defineProperty 还是 .prototype?
我已经看到了两种在 javascript 中实现非本机功能的不同技术,首先是:
第二是:
我知道第二种方法用于将任何方法附加到特定标准内置对象的原型链上,但第一种技术对我来说是新的。任何人都可以解释它们之间有什么区别,为什么使用一个,为什么不使用一个以及它们的意义是什么。
javascript - JavaScript try...catch for defineProperty 不起作用
我想知道当我使用andObject.defineProperty()
方法时,为什么在 catch 块内没有引发错误?get()
set()
javascript - 如何在传递 setter 时使用 = 赋值?
我正在一个遗留库函数上编写一个兼容层,其内部签名看起来像 -</p>
但是,新系统不建议直接分配自定义属性context
,而是建议使用该context.set()
方法。
我如何context
从新系统传递到旧系统,以便context.foo="data"
最终被调用context.set('foo', data)
?
我猜我可以为此使用 Object.defineProperty ,但我不太明白如何。