我正试图从'ionic-angular'导入“本地存储”,它说我 “LocalStorage未定义”.. 另外我得到了这个错误
RangeError:超出最大调用堆栈大小 在deepClone(C:\ Users \ Adir \ MyApps \ ToDoApp \ node_modules \ rollup \ dist \ rollup.js:153:20) 在deepClone(C:\ Users \ Adir \ MyApps \ ToDoApp \ node_modules \ rollup \ dist \ rollup.js:165:18) 在deepClone(C:\ Users \ Adir \ MyApps \ ToDoApp \ node_modules \ rollup \ dist \ rollup.js:165:18) 在deepClone(C:\ Users \ Adir \ MyApps \ ToDoApp \ node_modules \ rollup \ dist \ rollup.js:165:18) 在deepClone(C:\ Users \ Adir \ MyApps \ ToDoApp \ node_modules \ rollup \ dist \ rollup.js:165:18) 在deepClone(C:\ Users \ Adir \ MyApps \ ToDoApp \ node_modules \ rollup \ dist \ rollup.js:165:18) 在deepClone(C:\ Users \ Adir \ MyApps \ ToDoApp \ node_modules \ rollup \ dist \ rollup.js:165:18) 在deepClone(C:\ Users \ Adir \ MyApps \ ToDoApp \ node_modules \ rollup \ dist \ rollup.js:165:18) 在deepClone(C:\ Users \ Adir \ MyApps \ ToDoApp \ node_modules \ rollup \ dist \ rollup.js:165:18) 在deepClone(C:\ Users \ Adir \ MyApps \ ToDoApp \ node_modules \ rollup \ dist \ rollup.js:165:18)
我第一次在今天早上收到这些错误。昨天我和另一个离子2项目合作得很好。
顺便说一下,这是我的代码 import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import {Storage,LocalStorage} from 'ionic-angular';
/*
Generated class for the Admin page.
See http://ionicframework.com/docs/v2/components/#navigation for more info on
Ionic pages and navigation.
*/
@Component({
selector: 'page-admin',
templateUrl: 'admin.html'
})
export class AdminPage {
data: any;
public local: Storage;
public getsession:any;
constructor(public navCtrl: NavController) {
this.data={};
this.data.title="";
this.data.desc="";
this.local=new Storage(LocalStorage);
this.local.set('session','true');
this.getsession=this.local.get('session');
this.getsession.then((value)=>{
let x=value;
console.log(x);
})
}
ionViewDidLoad() {
}
}
答案 0 :(得分:1)
离子存储已转移到'@ ionic / storage' 截至rc.0
所以
import { Storage } from '@ionic/storage';
您无法指定其localstorage / sql还是其他任何内容。但它按顺序使用每个,直到它能够使用它。
只需创建一个实例并使用它
new Storage().set("key","value");
答案 1 :(得分:0)
旧问题......但它刚出现在我的Google搜索结果中:
import { Storage } from '@ionic/storage';
截至RC4的电流