我对 Salesforce 很陌生。我正在使用一些变量,这些变量在这个控制器内的多个方法中很常见。有没有办法定义一次变量并在这个组件方法中重用它们?
控制器
doInit : function(cmp, event, helper) {
var categoryUsed = 'Abc';
var locations = ['ten', 'twenty', 'thirty'];
var address = window.location.search;
//other logic1
},
handleFlag : function(cmp, event, helper) {
var categoryUsed = 'Abc';
var locations = ['ten', 'twenty', 'thirty'];
var address = window.location.search;
//other logic2
},
handleArea : function(cmp, event, helper) {
var categoryUsed = 'Abc';
var locations = ['ten', 'twenty', 'thirty'];
var address = window.location.search;
//other logic3
}
有没有办法一次性声明这些公共变量(categoryUsed、locations、address)并在该组件内的所有上述方法中使用?