怎么使用storage的getItem()方法同步獲取存儲的數據,因為異步執行帶來了很多的不便,特么是在封裝函數,將取到的值作為返回值時如以下函數:const serverPath = async function serverPath() {
const apiBase = '';
const storage = weex.requireModule('storage');
storage.getItem('apiBase', (e) => {
apiBase = e.url;
});
return apiBase;
};這只是一種形式,我只想在拿到本地數據,并返回。想知道有沒有什么比較好的方式來解決這個問題。我在iOS中發現有同步函數,但是發現SDK的實現方式都是使用block返回的。這樣同樣無法很好地處理返回值的問題
添加回答
舉報
0/150
提交
取消