Tag: ion3

离子 – 关于版本的困惑

这是我的客户端package.json : { "name": "ionic-hello-world", "author": "Ionic Framework", "homepage": "http://ionicframework.com/", "private": true, "scripts": { "clean": "ionic-app-scripts clean", "build": "ionic-app-scripts build", "ionic:build": "ionic-app-scripts build", "ionic:serve": "ionic-app-scripts serve" }, "dependencies": { "@angular/animations": "^4.1.3", "@angular/common": "4.1.3", "@angular/compiler": "4.1.3", "@angular/compiler-cli": "4.1.3", "@angular/core": "4.1.3", "@angular/forms": "4.1.3", "@angular/http": "4.1.3", "@angular/platform-browser": "4.1.3", "@angular/platform-browser-dynamic": "4.1.3", "@angular/platform-server": "4.1.3", "@ionic-native/core": "3.12.1", "@ionic-native/device": "^3.12.1", "@ionic-native/file-opener": "^3.12.1", […]

我将如何从离子存储返回我的对象​​

我正在进行项目更新,其中dashboard页面有3, 000行code 。 我想坚持以前的工作 所以我想转换这个function returnUserDetails(){ var userDetails = JSON.parse(localStorage.getItem("userData")); return userDetails ; } 到这一个,但给undefined返回值的error returnUserDetails(){ var userData; this.storage.get('userData').then((val) => { userData = JSON.parse(val); }); return userData; } 问题:我不能使用全局variables,因为这个函数使用了很多次。 我如何正确返回值