chende008 / react-native-easy-app Goto Github PK
View Code? Open in Web Editor NEWSimpler storage, Simpler fetch, Simpler UI
Simpler storage, Simpler fetch, Simpler UI
停更了吗?
我首先在config定义了 RNStorage,
export const RNStorage = {
mobile: undefined,
token: undefined,
json: undefined,//测试符串
};
引用后使用XStorage.initStorage 存储
XStorage.initStorage(RNStorage, () => {
RNStorage.token = res.data.token;
console.log('token9999=' + RNStorage.token);
});
res.data.token是后端API返回的token,当前的console可以拿到token数据,然后请求后跳转的页面也可以取到token,但是重新刷新页面后,判断当前token是否存在,一直拿不到token,一直获取的是undefined,正常逻辑是如果token存在进到首页,否则去登陆页,我是在设置路由的时候判断当前走主页还是登陆页,Navigation.setRoot(isLoggedIn() ? Routers : LOGIN); isLoggedIn是获取token的一个方法,但是此方法打印的 console.log(RNStorage.token,666) 一直是undefined ,麻烦问下是使用的方法不对吗😂
export default class HttpConfig { static init() { XHttpConfig() .initBaseUrl(APP_SERVE_URL_BD) .initTimeout(15000) .initHttpLogOn(false) .initContentType(XHttpConst.CONTENT_TYPE_URLENCODED) .initLoadingFunc((isLoading) => {}) .initHeaderSetFunc((headers, request) => { // console.log(headers,request) }) .initParamSetFunc((params, request) => { // console.log(params,request) }) .initParseDataFunc((result, request, callback) => { let {success, json, message, status, response} = result; console.log("===================") }) .initEncodeURIComponent(false); } }
initParseDataFunc方法不进入,initHeaderSetFunc、initParamSetFunc方法是可以进入的,能看一下是什么原因吗?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.