4
所以我有这样在这种情况下,我有可能提到钥匙吗?
this.PauseFunctions = {
2: {
OnSlideTo: function() {
console.log("The OnSlideTo function of the event at the 2-second mark was called");
},
OnSlideAway: function() {
console.log("The OnSlideAway function of the event at the 2-second mark was called");
}
},
5: {
OnSlideTo: function() {
console.log("The OnSlideTo function of the event at the 5-second mark was called");
},
OnSlideAway: function() {
console.log("The OnSlideAway function of the event at the 5-second mark was called");
}
}
};
的数据结构,我想知道如果我能够参考其值是包含OnSlideTo
函数的对象的关键。例如,在
2: {
OnSlideTo: function() {
console.log("The OnSlideTo function of the event at the 2-second mark was called");
},
OnSlideAway: function() {
console.log("The OnSlideAway function of the event at the 2-second mark was called");
}
}
我不知道是否有一种方法将其更改为
2: {
OnSlideTo: function() {
console.log("The OnSlideTo function of the event at the " + key + "-second mark was called");
},
OnSlideAway: function() {
console.log("The OnSlideAway function of the event at the " key + "-second mark was called");
}
}
其中key
是2
使我的程序可以更加普遍和维护。
即不可能的,因为每个对象进行评价的方式。 –
为什么你需要树的功能呢? – Amit