zoukankan      html  css  js  c++  java
  • vue-cli 2.x 搭建项目

    一、vue-cli优势

    1.成熟的vue项目架构设计

    2.本地测试服务器

    3.集成打包上线方案

    二、系统要求

    1.node.js

    2. Git

    3.node命令行终端

    三、安装

    1.安装vue-cli

    npm install vue-cli -g

    2.初始化项目

    vue init webpack myproject

    3.安装项目依赖

    npm install

    4. 在localhost启动测试服务器  npm run dev

    生成上线目录 npm run build

    四、 安装vue-router

    cnpm install vue-router --save (保存配置)

    五、 安装vuex (状态管理)

    cnpm install vuex --save

    六、 安装 vue-resource

    npm install vue-resource

    Vue.use(VueResource)

    在<script>中,created(生命周期): function(){

    this.$http.get('请求地址').then(function(data){},function(err){})

    this.$http.post('请求地址',{‘userid':123}(参数)).then(function(data){},function(err){})

    }

    then前面的部分构成了一个promise对象,所以可以调用then方法。

    七、安装 json-server

    cnpm install -g json-server 

    在命令行中, json-server --watch  db.json --port 3004

    接着,访问http://localhost:3004即可

  • 相关阅读:
    spring-boot4
    spring-boot3代码
    spring-boot3
    spring-boot2代码
    spring-boot2
    Java Socket编程
    eclipse项目中.classpath文件详解
    spring-boot1
    ASCII 在线转换器
    如何在Android开发中让你的代码更有效率
  • 原文地址:https://www.cnblogs.com/ceceliahappycoding/p/10397392.html
Copyright © 2011-2022 走看看