搭建vue开发环境

1.安装node,添加环境变量

2.添加全局缓存和模块存放路径

npm config set cache "D:\nodejs\node_cache"
npm config set prefix "D:\nodejs\node_global"

3.使用淘宝镜像

npm install -g cnpm --registry=https://registry.npm.taobao.org

4.将模块存放路径添加到path

D:\nodejs\node_global

5.安装vue

npm install vue -g

6.安装vue-cli脚手架

npm install vue-cli -g

7.新建项目

vue init webpack vadmin
cd vadmin
npm install
mpn run dev

看恩吧

8.编译打包

npm run build

9.配置跨域

apache

Header set Access-Control-Allow-Origin *

vue.config.js

devServer: {
    port: port,
    open: true,
    overlay: {
        warnings: false,
        errors: true
    },
    proxy: {
        '/api': {
            target: 'http://la2.com/',
            changeOrigin: true,
            pathRewrite: {
                '^/api': ''
            }
        }
    }
},

10.线上环境

设置 baseurl 

看恩吧

apache 转发

<VirtualHost *:80> 

    其他配置


    ProxyPass /api/ http://la2.com/

    ProxyPassReverse /api/ http://la2.com/

</VirtualHost>


nginx 转发

    location ^~ /api/ {

       proxy_pass   http://la2.com;

    }


看恩吧
网站不承担任何有关评论的责任
  • 最新评论
  • 总共条评论
取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦