【问题标题】:No MODULE named markup://lgc:bg found : [markup://c:accountManagerApex]找不到名为 markup://lgc:bg 的模块:[markup://c:accountManagerApex]
【发布时间】:2020-04-25 07:35:23
【问题描述】:

我创建了用于显示帐户的 LWC,并创建了一个 Lighting Web 组件和一个顶点类,如下所示。 HTML 文件

   <template>
    <lightning-card title="Showing Account(tile)">
        <template if:true={successResponse}>
            <template for:each={accounts} for:item="account">
                <li key={account.id}>
                    <div class="slds-p-around_medium lgc-bg">
                        <lightning-tile label={account.Name} href="/path/to/somewhere">
                            <p class="slds-truncate" title={account.Phone}>Account's Phone Number is : 

{account.Phone}
                            </p>
                        </lightning-tile>
                    </div>
                </li>
            </template>
        </template>
    </lightning-card>
</template>

Js.file

import { LightningElement, wire, track } from "lwc";
import allAccount from "@salesforce/apex/AcountManager.getAccount"

export default class AccountManagerApex extends LightningElement {

  @wire(allAccount)
  accountRecrd;

  successResponse (){
    if(this.accountRecrd){
      return true;
    }
    return false;
  }

}

类是:

公开与共享类 AcountManager {

    @AuraEnabled( cacheable = true) 
    public static List<Account> getAccount(){

        return [SELECT Id,Name,Phone,Website FROM Account Limit 10];
    }
}

当我尝试使用 VSCode 部署到我的组织时,出现以下错误。

错误

force-app\main\default\lwc\accountManagerApex\accountManagerApex.js 找不到名为 markup://lgc:bg 的模块:[markup://c:accountManagerApex]

谁能告诉我如何解决这个问题/

提前致谢,

【问题讨论】:

    标签: salesforce salesforce-lightning lwc


    【解决方案1】:

    您有一个自定义 css 类 lgc-bg。请确保您的 css 文件在选择器之前有句点

    /* incorrect, lwc tries to find lgc:bg component */
    lgc-bg : {}
    /* correct */
    .lgc-bg {}
    

    【讨论】:

      【解决方案2】:

      尝试在组件的 meta.xml 文件中设置&lt;isExposed&gt;true&lt;/isExposed&gt;

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2014-02-27
        • 2014-12-31
        • 1970-01-01
        • 2021-05-21
        • 1970-01-01
        • 1970-01-01
        • 2012-06-19
        • 2017-12-25
        相关资源
        最近更新 更多