## 通用构建方式使用方法

一般采用npm的装包方式，如果有问题采用yarn的方式装包

```code[javascript]
"niceloo-framework-vue2": "latest",
/* 运行的依赖包 */
   SpaBuild 所依赖包
/* 运行的依赖包 */
"niceloo-builds": "latest",
"@theshy/v-resize": "^1.1.2",
"nprogress": "0.2.0",
"babel-polyfill": "6.26.0",


/* element-doc所依赖包 */
   参考 SpaBuild 所依赖包
/* element-doc所依赖包  */

```

### 简易配置 必须配置首页路由逻辑！
```code[javascript]
   //main.js
import {initApp} from "niceloo-framework-vue2" ;
import {routes} from "./menu-routes"
/* 解析md文件需要导入的 */
import "niceloo-framework-vue2/element-doc"
/*加载路由*/
app.BaseService.addRoutes([
    {
        path:"/",component:()=>import("./main.vue"),children:routes
    }
], '/');
/*初始化应用*/
initApp();
```

### 全量配置 必须配置首页路由逻辑！
```code[javascript]
   //main.js
import {initApp} from "niceloo-framework-vue2" ;
import setting from './store/setting';
import routes from "./router/index";
import dictMap from "./dict";
import config from "./config/config";

/* 解析md文件需要导入的 */
import "niceloo-framework-vue2/element-doc"

/* 路由模式 默认history */
app.BaseService.setRouterMode("hash");
/*开启routerview的调试状态，可看到区块的缓存状态*/
app.RouterViewUtil.debug();
/*加载初始App组件*/
app.BaseService.setGlobalApp(() => import("./App"));
/*加载store模块*/
app.BaseService.addStoreModules("setting", setting);
/*加载路由*/
app.BaseService.addRoutes(routes);
/*通用404页的路由注入必须在所有路由都add完毕之后 默认错误路由自动转发至首页*/
// BaseService.addRoutes(
//     {
//         path: '**', // 错误路由
//         redirect: '/error/e404' //重定向
//     });
app.BaseService.addRouterBeforeEach(function (to, from, next) {
        next({path: '/error/e404'});
});
/*加载配置*/
app.Config.load(config);
/*加载字典*/
app.Dictionary.load(dictMap);
app.BaseService.setAppCreatedHandler(function () {
    // PageUtil.navigateTo("/demo/layout")
});
/*初始化应用*/
initApp();


```

### 路由编辑demo
```code[javascript]
export default [
    { path: "/", name: "home", component: () => import("../pages/home.vue") },
    { path: "/choice", name: "choice", component: () => import("../pages/choice") },
    { path: "/result", name: "result",meta: {
        needLogin:true
        }, component: () => import("../pages/result") },
];

```
