Javascript 如何使用循环以表格形式打印Localstorage数组值?
我将表单提交存储在localstorage key中,作为数组“fsubs”,如下所示:Javascript 如何使用循环以表格形式打印Localstorage数组值?,javascript,angular,typescript,local-storage,angular-local-storage,Javascript,Angular,Typescript,Local Storage,Angular Local Storage,我将表单提交存储在localstorage key中,作为数组“fsubs”,如下所示: var fsubs = JSON.parse(localStorage.getItem('fsubs') || "[]"); var fcodes = {"barcodeno" : this.form.value.barcode, "reelno" : this.form.value.reelno, "width" : this.form.value.width, "dia" : this.form.val
var fsubs = JSON.parse(localStorage.getItem('fsubs') || "[]");
var fcodes = {"barcodeno" : this.form.value.barcode, "reelno" : this.form.value.reelno, "width" : this.form.value.width, "dia" : this.form.value.dia, "weight" : this.form.value.weight};
fsubs.push(fcodes);
localStorage.setItem('fsubs', JSON.stringify(fsubs));
现在的问题是,我必须以表格形式打印这些值,比如使用循环,但我不知道怎么做
条形码|卷号
122121 | 232323 备注:我想在我的组件中使用Angular中的typescript打印此内容 组件1.ts:
fsubList:Array<any> = JSON.parse(localStorage.getItem('fsubs'));
fsubList:Array=JSON.parse(localStorage.getItem('fsubs'));
模板:
<table>
<tr>
<th>Barcode</th>
<th>Reelno</th>
</tr>
<tr *ngFor="let item of fsubList">
<td>{{item.barcodeno}}</td>
<td>{{item.reelno}}</td>
</tr>
</table>
条形码
里尔诺
{{item.barcodeno}
{{item.reelno}
我收到了这个错误错误:Uncaught(承诺中):TypeError:JSON.Parse不是一个函数
console.log(localStorage.getItem('fsubs'))
并显示输出是错误:Uncaught(承诺中):TypeError:JSON.Parse不是一个函数
它来自控制台,在解析中使用smallp
JSON.parse