我正在使用来自'@ ionic / storage'存储
的 import {Storage}运行时错误使用 this.storage.remove('key'); 时无法读取未定义属性'删除'
这是我使用的功能代码:this.storage.remove
logout(): void {
this.storage.remove(this.HAS_LOGGED_IN);
this.storage.remove('email');
this.events.publish('user:logout');
};
答案 0 :(得分:0)
你必须在构造函数中注入一个count
对象:
storage
请注意,您还必须在应用中注册存储模块:
import { Storage } from '@ionic/storage';
constructor(private storage: Storage) {
}
logout(): void {
this.storage.remove(this.HAS_LOGGED_IN);
this.storage.remove('email');
this.events.publish('user:logout');
};
答案 1 :(得分:0)
安装ionic-native包> $ npm install ionic-native --save
并使用它:
import { Storage } from 'ionic-native
//and in component class call it like this
Storage.remove('email');
如果你没有使用包装,你不需要注入它