MOD
![Join the chat at https://gitter.im/rapiop-mod/community](https://camo.githubusercontent.com/fbe5df40cdb9c44b13141fb75763f9995b49805768579b437c9e74f443e8646c/68747470733a2f2f6261646765732e6769747465722e696d2f726170696f702d6d6f642f636f6d6d756e6974792e737667)
安装
引用
import mod from '@rapiop/mod';
// 导入 amd 支持
import amdResolver from '@rapiop/mod/lib/resolver/amd';
// 注册模块类型解析器
mod.registerModuleResolver(amdResolver);
使用
// 添加模块配置
mod.config({
modules: {
react: {
type: 'amd',
js: 'https://cdn.jsdelivr.net/npm/react@16.13.1/umd/react.production.min.js'
},
'react-dom': {
type: 'amd',
js: 'https://cdn.jsdelivr.net/npm/react-dom@16.13.1/umd/react-dom.production.min.js',
dep: 'react'
}
}
});
(async () => {
// 加载模块
const [React, ReactDOM] = await mod.import(['react', 'react-dom']);
// 使用模块
ReactDOM.render(React.createElement('button', {}, 'test'), document.getElementById('app'));
})();
使用教程