moudle-cli
moudle-cli 是 创建 业务组件 产品工程模板的命令行工具
安装
npm install -g moudle-cli
使用
moudle -v // 查看当前cli版本
moudle -h // 命令帮助信息
moudle create <projectName> // 创建业务组件的工程模板,可以指定模板类型及其版本
目录结构
│ index.js
│ package.json
│
├─lang
│ cn.js
│ en.js
│
├─pages
├─router
│ index.js
│
└─store
index.js
index.js
import router from './router'
import store from './store'
import cn from './lang/cn'
import en from './lang/en'
const lang = { cn, en }
export { router, store, lang }
export default { router, store, lang }
主要输出router,store,lang,不要随意修改。也可以拓展新的业务。
router/index.js
import Telephone from '../pages/telephone'
import TelephoneSearch from '../pages/telephoneSearch'
let routes = [
{
path: '/LM_FE_H5_phone/telephone',
name: 'telephone',
component: Telephone,
meta: {
title: 'LM_FE_H5_lang_phone.title'
}
},
{
path: '/LM_FE_H5_phone/telephoneSearch',
name: '/LM_FE_H5_phone/telephoneSearch',
component: TelephoneSearch,
meta: {
title: 'LM_FE_H5_lang_phone.title'
}
}
]
export default routes
title 由原来的 ‘i18n.t('LM_FE_H5_lang_phone.title')’ 改为 ‘LM_FE_H5_lang_phone.title’ 即可
国际化命名规范
前缀 LM_FE_H5_lang_ + 业物组件名
例: 常用电话(LM_FE_H5_lang_phone)
路由定义规范
path与name相同
/(package.json中name)/子路由名
例如:/LM_FE_H5_phone/telephone