0

我收到此错误消息。不知道为什么。我没有遗漏任何分号

错误:解析错误。“标识符”预期 newLeadClick :功能(组件,事件,助手){

    newLeadClick : function(component, event, helper) {
        const workspaceAPI = component.find("workspace");
            workspaceAPI.getEnclosingTabId().then(function(tabId) {
                const tabContext = {
                    parentTabId: tabId,
                        url: '/lightning/r/Lead/'+component.get("v.LeadId")+'/view',
                            focus: true
            }
            helper.openWorkspaceSubTab(component, workspaceAPI, tabContext);
       });
    },
 /**
  *This function is responsible for opening the opportunity page in subtab in readmode on click of Open Opportunity Button
  */
    newOppClick : function(component, event, helper) {
       const workspaceAPI = component.find("workspace");
        workspaceAPI.getEnclosingTabId().then(function(tabId) {
            const tabContext = {
                parentTabId: tabId,
                url: '/lightning/r/Opportunity/'+component.get("v.OppId")+'/view',
                focus: true
            }
            helper.openWorkspaceSubTab(component, workspaceAPI, tabContext);
       });
   },
4

3 回答 3

0

这是整个代码

({
    doInit : function(component, event, helper) {
        helper.getLeadId(component);
    },
    /**
     *This function is responsible for opening the lead page in read mode on click of Open Lead button
     */
    newLeadClick : function(component, event, helper) {
       const workspaceAPI = component.find("workspace");
        workspaceAPI.getEnclosingTabId().then(function(tabId) {
            const tabContext = {
                parentTabId: tabId,
                url: '/lightning/r/Lead/'+component.get("v.LeadId")+'/view',
                focus: true
            }
            helper.openWorkspaceSubTab(component, workspaceAPI, tabContext);
       });
    },
 /**
  *This function is responsible for opening the opportunity page in subtab in readmode on click of Open Opportunity Button
  */
    newOppClick : function(component, event, helper) {
       const workspaceAPI = component.find("workspace");
        workspaceAPI.getEnclosingTabId().then(function(tabId) {
            const tabContext = {
                parentTabId: tabId,
                url: '/lightning/r/Opportunity/'+component.get("v.OppId")+'/view',
                focus: true
            }
            helper.openWorkspaceSubTab(component, workspaceAPI, tabContext);
       });
   },
     afterSaveOpp : function(component, event, helper) {
        component.set("v.showRecord", true);
    },
    /**
     * this function is responsible for creating a default lead and attach it to transcript,
     * and then open the same lead inside a lightning component in a new sub tab for user
     * to add/modify the fields and save
     */
    afterSaveLead : function(component, event, helper) {
        component.set("v.editmode", true);
        const action = component.get("c.attachToTranscript"); 
        action.setParams({ leadId : null, chatTranscriptId: component.get("v.recordId")});
        action.setCallback(this, function(response) {
            const state = response.getState();
            const result = response.getReturnValue();
            if (state === "SUCCESS"){
                component.set("v.LeadId", result);
                component.set("v.showRecord", false);
                const workspaceAPI = component.find("workspace");
            workspaceAPI.getEnclosingTabId().then(function(tabId) {
                    const tabContext = {
                        parentTabId: tabId,
                        pageReference: {
                            "type": "standard__component",
                            "attributes": {
                                "componentName": "c__ShowLeadEditMode"  // c__<comp Name>
                            },
                            "state": {
                                "c__leadid": component.get("v.LeadId") // c__<comp attribute Name>
                            }
                        },
                        focus: true
                    }
                    helper.openWorkspaceSubTab(component, workspaceAPI, tabContext);
                });
                
            } else {
                 helper.showToast(component);
            }
            component.set("v.showSpinner", false);
        });
        $A.enqueueAction(action);
         },
});
于 2020-11-16T03:28:05.410 回答
0

此类错误的原因通常是对象或数组定义中的逗号错误:

var obj = {
  id: 40,
  name: "objectTest",  <--
}

它在您的代码中查找,在箭头指向的末尾有一个额外的逗号:

afterSaveLead : function(component, event, helper) {
    component.set("v.editmode", true);
    const action = component.get("c.attachToTranscript"); 
    action.setParams({ leadId : null, chatTranscriptId: component.get("v.recordId")});
    action.setCallback(this, function(response) {
        const state = response.getState();
        const result = response.getReturnValue();
        if (state === "SUCCESS"){
            component.set("v.LeadId", result);
            component.set("v.showRecord", false);
            const workspaceAPI = component.find("workspace");
        workspaceAPI.getEnclosingTabId().then(function(tabId) {
                const tabContext = {
                    parentTabId: tabId,
                    pageReference: {
                        "type": "standard__component",
                        "attributes": {
                            "componentName": "c__ShowLeadEditMode"  // c__<comp Name>
                        },
                        "state": {
                            "c__leadid": component.get("v.LeadId") // c__<comp attribute Name>
                        }
                    },
                    focus: true
                }
                helper.openWorkspaceSubTab(component, workspaceAPI, tabContext);
            });
            
        } else {
             helper.showToast(component);
        }
        component.set("v.showSpinner", false);
    });
    $A.enqueueAction(action);
     },        <--
});
于 2020-11-16T03:50:26.487 回答
0

我确实用分号修复了一些逗号。现在我得到这个错误

参数必须有 JSDoc。newLeadClick : 函数(组件、事件、助手){

于 2020-11-16T04:33:06.540 回答