创建vue项目

安装vue-cli
    

npm install -g vue-cli / cnpm i -g vue-cli


查看版本
    

vue -V


使用vue-cli创建项目
    

    vue init webpack demo(项目是基于webpack的)
    Project name(工程名):回车
    Project description(工程介绍):回车
    Author:作者名
    Vue build(是否安装编译器):回车
    Install vue-router(是否安装Vue路由):回车
    Use ESLint to lint your code(是否使用ESLint检查js代码):n
    Set up unit tests(安装单元测试工具):n
    Setup e2e tests with Nightwatch(是否安装端到端测试工具):n
    Should we run npm install for you after the project has been created? (recommended):回车。


启动项目
    

    进入项目目录:cd demo
    安装项目所需要的依赖:npm install
    启动项目:npm run dev


安装sass
    

npm install less less-loader --save

安装axios(数据请求)
    

    npm install axios --save
    //main.js
    import axios from 'axios'
    Vue.prototype.$http=axios
    //测试环境配置config index.js
    proxyTable:{
      '/api': {
          // 测试环境
          target: 'http://www.baidu.com',    
          changeOrigin: true,    //跨域
          pathRewrite: {
              '^/api': ''    //替换target内容为/api
          }
      }
    },
    //使用
    that.$http.post('/example/example').then(function(res){
        console.log(res)
    })


去掉#号
    

    export default new Router({
      mode:'history',
      routes: [
        {
          path: '/',
          name: 'home',
          component: Home
        }
      ]
    })
    nigx配置添加
    location / {
         try_files $uri $uri/ /index.html;
    }

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值