Trailhead 的问题“亲身体验新的警报、确认和提示模块和组件”

Vla*_*huk 3 javascript salesforce lwc

我无法完成挑战“亲身体验新警报、确认和提示模块和组件”。我很确定这个挑战有一个错误,我想知道我犯了一个错误,或者这个挑战有错误。

分配:

import { LightningElement, api } from "lwc";
export default
class recordCardQuickFiles extends LightningElement {
 @api
 recordId;
 onDeleteAllFilesButtonClick() {
  const confirmation = confirm("Are you sure you want to delete all files?");
   if (confirmation) {
      //... proceed with
     //... Apex Logic to delete Files.
    //... We will not check this comment.
    }
  }
}
Run Code Online (Sandbox Code Playgroud)
  • 创建一个新的 Lightning Web 组件
  • 名称:recordCardQuickFiles
  • 从“闪电/确认”导入闪电确认
  • 将确认方法替换为 LightningConfirm 方法
  • 消息:“您确定要删除所有文件吗?”
  • 变体:“无标题”
  • 标签:“您确定要删除所有文件吗?”

我的解决方案:

import { LightningElement, api } from "lwc";
import LightningConfirm from "lightning/confirm";
export default
class recordCardQuickFiles extends LightningElement {
    @api
    recordId;
    configs = {
        Message: "Are you sure you want to delete all files?",
        Label: "Are you sure you want to delete all files?",
        Variant: "headerless"
    }
    onDeleteAllFilesButtonClick() {
        const confirmation = LightningConfirm.open(this.configs);
        if (confirmation) {
            //... proceed with
            //... Apex Logic to delete Files.
            //... We will not check this comment.
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

发生错误:您的.org 中的挑战尚未完成 LightningConfirm 方法中使用的消息不正确。

小智 5

LWC 的 JS 文件应类似于以下内容:

import { LightningElement, api } from "lwc";
import LightningConfirm from 'lightning/confirm';

export default
class recordCardQuickFiles extends LightningElement {
    @api
    recordId;
    onDeleteAllFilesButtonClick() {
        const confirmation = LightningConfirm.open({
            Message: 'Are you sure you want to delete all files?',
            Variant: 'headerless',
            Label: 'Are you sure you want to delete all files?'
        });
        if (confirmation) {
            //... proceed with
            //... Apex Logic to delete Files.
            //... We will not check this comment.
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

我希望这有帮助。谢谢!