我使用了MacOS 10.13和我的离子信息CLI软件包:
(在/ usr /本地/ LIB / node_modules)
@ionic/cli-utils : 1.19.2
ionic (Ionic CLI) : 3.20.0
全球套餐:
cordova (Cordova CLI) : 8.0.0
本地套餐:
@ionic/app-scripts : 3.1.8
Cordova Platforms : android 6.3.0
Ionic Framework : ionic-angular 3.9.2
系统:
Node : v8.11.0
npm : 5.6.0
OS : macOS High Sierra
环境变量:
ANDROID_HOME : not set
其他:
backend : pro
mycode.ts
this.storage.get('waitmsg').then((waitmsg) => {
if (waitmsg != null) {
this.http.post(link, data, httpOptions)
.subscribe(data => {
this.storage.ready().then(() => {
var msglist = {}
for(var msg in waitmsg) {
var receiveuser = waitmsg[msg]['receiveuser']
var mypk = waitmsg[msg]['userpk']
var content = waitmsg[msg]['content']
let setmsg = {
userpk: mypk,
receiveuser: receiveuser,
content: content,
createDate: new Date(),
read: 1
}
this.storage.get(receiveuser + ":" + mypk).then((data) => {
data.push(setmsg)
this.storage.set(receiveuser + ":" + mypk, data)
});
}
this.storage.remove('waitmsg')
});
}, error => {
alert("error")
});
}
});
waitmsg
[{'userpk': '11', 'receiveuser': '9', 'content': '1'},
{'userpk': '11', 'receiveuser': '9', 'content': '2'},
{'userpk': '11', 'receiveuser': '9', 'content': '3'},
{'userpk': '11', 'receiveuser': '3', 'content': '4'},
{'userpk': '11', 'receiveuser': '3', 'content': '5'},
{'userpk': '11', 'receiveuser': '9', 'content': '6'},
{'userpk':'11', 'receiveuser': '3', 'content': '7'}]
我测试了这段代码。 this.storage.get
至少运行一次。我希望它一直运行,我怎么能搞这个?