簡體   English   中英

我收到了這個錯誤,誰能告訴我如何解決這個問題

[英]I got this error ,can someone tell me how to fix this

core.js:4442 錯誤類型錯誤:無法讀取 null 的屬性“名稱”

    setTimeout(() => {
        this.userDetails = this.cacheService.getUser();
            this.userName = this.userDetails.name;
          }, 1000);

這意味着 object “userDetails” 等於 null 因此您無法從中獲取屬性“name”,您必須首先確保“userDetails”被分配了一個值,例如:

this.userDetails.name= "Jhon Doe"

嘗試在 your.HTML 頁面底部設置腳本

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM