Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | 1x 1x 1x 1x 1x 1x 1x 2x 1x 2x 1x 1x | import React from 'react'; import { MemoryMVC as MVC, Controller } from 'mvc-react'; import i18n from 'react-router-controller/libs/plugins/i18n'; function modelRegister(register) { //配置这些目录时,没有目录会报错,新建目录后还报错,可以新建一个空文件,保存以下其他文件触发重编译,就没问题了 Controller.set({ readViewFile(viewId, controllerId, firstLoad) { if (firstLoad) { import(/* webpackMode: "eager" */ `./model/${viewId}.js`) .then(model => { //注册sagaModel register(model.default); }) .catch(e => { //console.log(e); //console.trace(); }); } //view可以异步载入 return import(`./view/${controllerId}/${viewId}/index.jsx`).then( component => { return component.default; } ); }, readControllerFile(controllerId) { //webpackMode: eager是使import变为不异步,跟require一样, //但是返回的时promise对象,不能使用require,require会把没必要的文件载入 //最好不使用异步载入,可能导致一些问题 return import(/* webpackMode: "eager" */ `./controller/${controllerId}.js`) .then(controller => { return controller.default; }) .catch(e => { //必须catch并返回false return false; }); }, //插件 plugins: [ i18n(language => { return import(`./i18n/${language}.js`).catch(e => { console.log(e); return false; }); }, require('./i18n/zh_CN').default), ], //设置首页path(跳转路径,即react-router path='/'时,会跳转到indexPath) //第一个字符必须是'/',不能是main/index,要是绝对的路径 indexPath: '/main/index', }); } export default function container(props) { return ( <MVC basename={process.env.basename} modelRegister={modelRegister} hot={props.hot} /> ); } |