在小程序中集成redux/immutable/thunk第三方库
小程序给我们暴露了两个参数? module.exports = function(){}
所以只要需要让第三方库的代码使用这种形式的? 二、构建Redux的微信小程序包打一个? git clone https://github.com/reactjs/redux.git
npm install
# 详细内容可以到redux项目的package.json中查看
# 这些命令是是使用webpack构建UMD模式的包。也就是说所有的代码,包括依赖的库都会被打包到一个文件中,并且自带一段模块加载代码,文件可以在dist目录下找到
npm run build:umd && npm run build:umd
用编辑器打开? (function webpackUniversalModuleDefinition(root,factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
else if(typeof define === 'function' && define.amd)
define([],factory)typeof exports === 'object')
exports["Redux"] = factory();
else
root[;
})(this,function() {
...
})
三、集成Redux-devtools因为微信小程序的开发环境是定制的,暂时没有发现办法直接安装? 安装remote-redux-devtools
安装和启动remotedev-servernpm install -g remotedev-server
remotedev --hostname=localhost --port=5678
因为没办法用? 集成devtool在? const {createStore,compose} = require('./libs/redux.js');
const devTools = './libs/remote-redux-devtools.js').default;
const reducer = './reducers/index.js')
function configureStore() {
return createStore(reducer,compose(devTools({
hostname: 'localhost',port: 5678,secure: false
})));
}
module.exports = configureStore;
把?
四、小程序中集成immutable
Immutable使用了UMD模块化规范' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global.Immutable = factory());
}('use strict';var SLICE$0 = Array.prototype.slice;
....
}));
修改? 导入修改好的? immutable ?到小程序中即可?https://github.com/poetries/wx-redux-immutable-template/blob/master/wx-redux-immutable-template/public/libs/immutable.js (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |