gpt4 book ai didi

javascript - 引用对象内部的父变量

转载 作者:行者123 更新时间:2023-12-04 20:21:37 25 4
gpt4 key购买 nike

<分区>

我正在处理一个 JavaScript 对象,其中声明了很多变量。我想要做的是引用父对象的另一个子对象。给定以下对象:

var clusters = {

auxiliars: {
environment : "Development",
local_storage_key : "Cluster",

iqns_class : ".iqn",
iqn : this.iqns_class.parent(),

viewport : $(window),

viewport_width : this.viewport.width(),
viewport_height : this.viewport.height(),

plugin : {
containerID : "",
first : false,
previous : false,
next : false,
last : false,
startPage : 1,
perPage : 6,
midRange : 6,
startRange : 1,
endRange : 1,
keyBrowse : false,
scrollBrowse: false,
pause : 0,
clickStop : true,
delay : 50,
direction : "auto",
animation : "fadeIn",
links : "title",
fallback : 1000,
minHeight : true,
callback : function(pages, items) {}
}
},

set_local_storage_data: function(data_val) {
return localStorage.setItem(auxiliars.local_storage_key, data_val);
},

get_local_storage_data: function() {
return +(localStorage.getItem(auxiliars.local_storage_key) || 1);
},

set_environment: function(environment) {
if(auxiliars.environment == "Development") {
less.env = "development";
less.watch();
}
},

shop_iqns_selected_class: function() {
if (auxiliars.viewport_width < 980) {
$(auxiliars.iqns_class).each(function(index, element) {
var element = $(element);
$(auxiliars.iqn).on('click', function() {
if (element.hasClass('selected')) {
element.removeClass('selected');
} else {
element.addClass('selected');
}
});
});
}
},

initiate_plugin: function(plugin_navigation, plugin_options) {
var options = $.extend({}, auxiliars.plugin, plugin_options);
return $(plugin_navigation).jPages(options);
}

}

您会注意到 this.viewport.width(),通过它我想指向在同一 auxiliars 中声明的 viewport 变量目的。显然我遇到了错误,但我如何才能指向同一对象的子值?

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com