提问人:Koby K 提问时间:5/22/2023 最后编辑:Koby K 更新时间:5/22/2023 访问量:24
如何在没有 getter 的情况下访问对象内部的对象属性,同时访问属性中的函数?(JavaScript的)
How can I access an object property inside the object while inside a function in the property without a getter?(javascript)
问:
我有这个代码,我希望我的所有代码都在一个没有例外的主对象中:
var inputs = [];
var Ivh = {
addInput: (input, display, message, regex) => {
inputs.push([input, display, message, regex, input.value]);
}
}
然而,这是行不通的:
var Ivh = {
inputs: [],
addInput: (input, display, message, regex) => {
inputs.push([input, display, message, regex, input.value]);
}
}
如何将输入变量转换为 Ivh 的属性?我试图找到使用 getter 从对象内部访问对象属性的方法,但这两者都不起作用。即。(这不允许我调用 Ivh 的 addInput 函数,并且 getter 不接受参数)
答: 暂无答案
评论
this.inputs.push()
this.
this.inputs.push()
push
this.inputs
undefined
addInput()
Ivh