[英]salesforce lightning component init function call
I am trying to check something before the modal popup shows in salesforce opportunity page.我正在尝试在 Salesforce 机会页面中显示模式弹出窗口之前检查一些内容。 When I call the doInit function the button handler functions stop working.
当我调用 doInit 函数时,按钮处理函数停止工作。 My code is
我的代码是
<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>
and the controller is控制器是
( {
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();
}
});
The format for your controller is incorrect.您的控制器格式不正确。 The format should be basically a JSON like this:
格式应该基本上是这样的 JSON:
{
method1 : function (component, event, helper){},
method2 : function (component, event, helper){}
}
You have extra curly braces after the doInit method.在 doInit 方法之后有额外的花括号。 It should be like this:
应该是这样的:
({
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();
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.