vuejs怎么在服务器部署?

经过npm run build 把生成的dist文件夹(不要上传文件夹)里的内容上传到http服务器上就能够经过 http来访问了,开发机上正常,上传之后 程序出现错误不能运行的缘由99.99%的可能性是你引用资源的路径有问题。css

用vue-cli搭建的作法
一、npm run build
二、把dist里的文件打包上传至服务器 例 /data/www/,我通常把index.html放在static里
因此个人文件路径为:html

/data/www/static
|-----index.html
|-----js
|-----css
|-----images
....vue

三、配置nginx监听80端口, location /static alias 到 /data/www/static,重启nginx
location /static {
alias /data/www/static/;
}
四、浏览器访问便可


参考:https://www.zhihu.com/question/46630687/answer/102284339
相关文章
相关标签/搜索