【发布时间】:2021-06-13 14:17:26
【问题描述】:
我是 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)声明一次,并在该组件内的所有上述方法中使用?
【问题讨论】:
标签: salesforce apex salesforce-lightning salesforce-communities aura-framework