当前位置: 首页 > news >正文

vue项目 前端加前缀(包括页面及静态资源)

具体步骤

Vue 中配置

(1)更改router模式,添加前缀

位置:router文件夹下面的index.js

const router = new Router({base: '/nhtjfx/', // 路由前缀mode: 'history', // 采用history模式URL的路径才跟配置的对应上,不然URL是先加/#再追加配置的地routes:[...]});

(2)实现静态文件加前缀
位置:vue.config.js

module.exports = {publicPath: '/nhtjfx/',
}

(3)nignx配置

server {listen       8088;server_name  localhost;#charset koi8-r;#access_log  logs/host.access.log  main;location /nhtjfx/ {alias /usr/local/linewell/web/nhjcfx/front/nhtjfx/;index index.html;try_files $uri $uri/ /nhtjfx/index.html;}#location / {# root  /usr/local/linewell/web/nhjcfx/front/nhtjfx;#vue前端项目打包后放在这里   #      root  /usr/local/linewell/web/nhjcfx/front/build;#      index  index.html index.htm;#这个index.html  是上面dist目录下的index.html#	    try_files $uri $uri/ /index.html; # 解决刷新出现404 #   }#error_page  404              /404.html;# redirect server error pages to the static page /50x.html#error_page   500 502 503 504  /50x.html;location = /50x.html {root   html;}}
http://www.lryc.cn/news/106250.html

相关文章:

  • 使用文心一言等智能工具指数级提升嵌入式/物联网(M5Atom/ESP32)和机器人操作系统(ROS1/ROS2)学习研究和开发效率
  • 【Rust 基础篇】Rust动态大小类型:理解动态大小类型与编写安全的代码
  • 【Python】使用nuitka打包Python程序为EXE可执行程序
  • 背景图片及精灵图
  • 简要介绍 | 生成模型的演进:从自编码器(AE)到变分自编码器(VAE)和生成对抗网络(GAN),再到扩散模型
  • 8.2Thread类的常见属性
  • 博客摘录「 mvvm框架工作原理及优缺」2023年7月31日
  • 第12章 Linux 实操篇-Linux磁盘分区、挂载
  • 使用express搭建后端服务
  • 深度学习——划分自定义数据集
  • Jmeter性能测试之正则表达式提取器
  • 浅谈Kubernetes中Service网络实现(服务发现)
  • 【重造轮子】golang实现可重入锁
  • torch显存分析——对生成模型清除显存
  • electron+vue+ts窗口间通信
  • 基于Fringe-Projection环形投影技术的人脸三维形状提取算法matlab仿真
  • 如何使用Webman框架实现多语言支持和国际化功能?
  • 接受平庸,特别是程序员
  • HTML兼容性
  • Java日期和时间处理入门指南
  • anndata k折交叉
  • 深入解析项目管理中的用户流程图
  • Vue使用QrcodeVue生成二维码并下载
  • “用户登录”测试用例总结
  • 适应于Linux系统的三种安装包格式 .tar.gz、.deb、rpm
  • Linux lvs负载均衡
  • Tomcat 创建https
  • 超导电性的基本现象和相关理论
  • 在 PHP 中单引号(‘ ‘)和双引号(“ “)用法的区别
  • SpringCloudAlibaba:服务网关之Gateway的cors跨域问题