瀏覽代碼

fix get local error

huaisianhuang 3 年之前
父節點
當前提交
590fef611f
共有 1 個文件被更改,包括 7 次插入1 次删除
  1. 7 1
      html/script_profiles.js

+ 7 - 1
html/script_profiles.js

@@ -9,10 +9,16 @@ function getCookie(name) {
   }
 
 let userBasics = JSON.parse(localStorage.getItem('user_profile')) || [];
-if(userBasics !== []){
+console.log(userBasics.length, typeof(userBasics));
+
+function checkLocal() {
+  if(userBasics.length == 0){ return };
   $('.userName').html(`<h2 class="user-name text-white mt-4 fw-bold">Hello,${userBasics.user_info.userName}</h2>`);
 }
 
+checkLocal()
+
+
 function renderView() {
     let token = getCookie('jwt_token');
     if(!token) {