yarn vue-cli 3+ 动态模块开发和tomcat与ng
2020-08-26 本文已影响0人
青色沙丘
1.vue项目携带一个#会对开发造成一定的影响,本项目使用的是history
整体结构 是vue+element-ui+vuex
一:npm

二:yarn

ps: 1.router 中代码

2.主页代码


整体模块使用component标签动态模块,getRouterAlive 是判断模块是否加载成功。changeActive和selectMenu和changeComponent 是自定义菜单组件进行切换模块用的。
其中ComsUtil是components.js 初始化加载/components/module下的所有模块。params 是动态组件见传值使用,也可以使用vuex也可以是使用全局$emit
components.js

2./components/module 模块的key名称与module下文件夹名称一致。每个module中完全独立,跟正常些*.vue一样,样式还是要加scope的否则会样式冲突


nginx部署与tomcat 部署区别
nginx:1.打包直接使用npm run build 跟本地测试一样。
2.修改conf,root 是dist文件夹的路径,访问路径不带/dist的这点要注意

tomcat:1.打包,修改Router中path APIObj.projectName实际上是全局一个变量,它的值就是打包后文件夹的名称dist。因为tomcat-webapps中非ROOT都需要带文件夹路径。

2.修改tomcat conf文件夹下的web.xml在最底部添加404,因为vue -history模式访问路径超过两层(/*/*)tomcat会走自己路由,导致访问不到vue的index.html
