最佳答案
我知道我不是第一个问这个问题的人,正如我在标题中提到的,我正在尝试转换字符串值布尔值。
I have previously put some values into local storage,Now I want to get all the values and assign all to the some boolean variables .
app.component.ts
localStorage.setItem('CheckOutPageReload', this.btnLoginNumOne + ',' + this.btnLoginEdit);
here this.btnLoginNumOne
and this.btnLoginEdit
are string values (“真,假”).
mirror.component.ts
if (localStorage.getItem('CheckOutPageReload')) {
let stringToSplit = localStorage.getItem('CheckOutPageReload');
this.pageLoadParams = stringToSplit.split(',');
this.btnLoginNumOne = this.pageLoadParams[0]; //here I got the error as boolean value is not assignable to string
this.btnLoginEdit = this.pageLoadParams[1]; //here I got the error as boolean value is not assignable to string
}
在这个分量中,this.btnLoginNumOn
e 和 this.btnLoginEdi
t 是 布尔型值;
我尝试了堆栈溢出的解决方案,但没有工作。
有人能帮我解决这个问题吗。