Explorar o código

fix get local error

huaisianhuang %!s(int64=3) %!d(string=hai) anos
pai
achega
590fef611f
Modificáronse 1 ficheiros con 7 adicións e 1 borrados
  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) {