我有一个问题,我的本地存储服务是字符串,但我需要使用数字,我是怎么做到的

I have a problem my localstorage service is string but i need to use number how i do that

这是我的服务

 import { Injectable } from '@angular/core';

@Injectable({
  providedIn: 'root',
})
export class LocalStorageService {
  constructor() {}

  setItem<T>(key: string, object: T) {
    localStorage.setItem(key, JSON.stringify(object));
  }

  getItem(key: string) {
    return JSON.parse(localStorage.getItem(key)!);
  }

  removeItem(key: string) {
    localStorage.removeItem(key);
  }

  isExist(key: string) {
    if (JSON.parse(localStorage.getItem(key)!)) {
      return true;
    } else {
      return false;
    }
  }
}

这是我的代码

  GetUserById() {
  
    this.authService.GetUserById(localStorage.getItem('Id')).subscribe(
      (response) => {
        this.user = response.data;
        
   

        this.editProfileForm.setValue({
          Id:this.user.Id,
          FirstName: this.user.FirstName,
          LastName: this.user.LastName,
          Email: this.user.Email,
          password: '',
          
        });
      },
      (responseError) => {
        this.toastrService.error(responseError.error);
      }
    );
  }

所以 'string' 类型的参数不能分配给 'number' 类型的参数。这是错误 所以我怎么能得到更多我应该改变我的服务或者我应该做什么我尝试了一些事情但我不能

this line is error >>>>>>>>>    this.authService.GetUserById(localStorage.getItem('Id')).subscribe <<<<<
 Number(localStorage)
  Number(this.authService)
 // 'Id',JSON.stringify(this.Id)
    this.authService.GetUserById(Number(localStorage.getItem("userId"))).subscribe(
      (response) => {
        this.user = response.data;
    
   console.log(response.data)

没人回答但我找到了