salesforce 闪电组件初始化函数调用
salesforce lightning component init function call
我正在尝试在 salesforce 商机页面中显示模式弹出窗口之前检查一些内容。当我调用 doInit 函数时,按钮处理函数停止工作。我的密码是
<aura:component implements="force:lightningQuickActionWithoutHeader,force:hasRecordId,force:appHostable,flexipage:availableForRecordHome,force:hasRecordId,force:hasSObjectName" access="global">
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<b>This is recordID {!v.recordId} </b><br/>
Are you sure you want to proceed?
<div class="slds-align_absolute-center">
<lightning:button
label="No"
variant="destructive"
onclick="{!c.handleNo}"
></lightning:button>
<lightning:button label="Yes" onclick="{!c.handleYes}"></lightning:button>
</div>
</aura:component>
控制器是
( {
doInit:function(component,event,helper){
alert(component.get("v.recordId"));
}
},
{
handleNo: function (component, event, helper) {
var urlEvent = $A.get("e.force:navigateToURL");
urlEvent.setParams({
url: "/apex/NQuote",
isredirect: "true"
});
urlEvent.fire();
},
handleYes: function (component, event, helper) {
var urlEvent = $A.get("e.force:navigateToURL");
urlEvent.setParams({
url: "/apex/TestPage",
isredirect: "true"
});
urlEvent.fire();
}
});
您的控制器格式不正确。格式基本上应该是这样的 JSON:
{
method1 : function (component, event, helper){},
method2 : function (component, event, helper){}
}
doInit 方法后有额外的大括号。应该是这样的:
({
doInit: function (component, event, helper) {
alert(component.get("v.recordId"));
},
handleNo: function (component, event, helper) {
var urlEvent = $A.get("e.force:navigateToURL");
urlEvent.setParams({
url: "/apex/NQuote",
isredirect: "true"
});
urlEvent.fire();
},
handleYes: function (component, event, helper) {
var urlEvent = $A.get("e.force:navigateToURL");
urlEvent.setParams({
url: "/apex/TestPage",
isredirect: "true"
});
urlEvent.fire();
}
});
我正在尝试在 salesforce 商机页面中显示模式弹出窗口之前检查一些内容。当我调用 doInit 函数时,按钮处理函数停止工作。我的密码是
<aura:component implements="force:lightningQuickActionWithoutHeader,force:hasRecordId,force:appHostable,flexipage:availableForRecordHome,force:hasRecordId,force:hasSObjectName" access="global">
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<b>This is recordID {!v.recordId} </b><br/>
Are you sure you want to proceed?
<div class="slds-align_absolute-center">
<lightning:button
label="No"
variant="destructive"
onclick="{!c.handleNo}"
></lightning:button>
<lightning:button label="Yes" onclick="{!c.handleYes}"></lightning:button>
</div>
</aura:component>
控制器是
( {
doInit:function(component,event,helper){
alert(component.get("v.recordId"));
}
},
{
handleNo: function (component, event, helper) {
var urlEvent = $A.get("e.force:navigateToURL");
urlEvent.setParams({
url: "/apex/NQuote",
isredirect: "true"
});
urlEvent.fire();
},
handleYes: function (component, event, helper) {
var urlEvent = $A.get("e.force:navigateToURL");
urlEvent.setParams({
url: "/apex/TestPage",
isredirect: "true"
});
urlEvent.fire();
}
});
您的控制器格式不正确。格式基本上应该是这样的 JSON:
{
method1 : function (component, event, helper){},
method2 : function (component, event, helper){}
}
doInit 方法后有额外的大括号。应该是这样的:
({
doInit: function (component, event, helper) {
alert(component.get("v.recordId"));
},
handleNo: function (component, event, helper) {
var urlEvent = $A.get("e.force:navigateToURL");
urlEvent.setParams({
url: "/apex/NQuote",
isredirect: "true"
});
urlEvent.fire();
},
handleYes: function (component, event, helper) {
var urlEvent = $A.get("e.force:navigateToURL");
urlEvent.setParams({
url: "/apex/TestPage",
isredirect: "true"
});
urlEvent.fire();
}
});