vue 安装详情

1 安装最新版 node,js

2 安装 git

3 打开 git-bash

npm install vue-cli -g安装 vue命令环境
验证安装ok?
vue --version
生成项目模板
vue init <模板名>
(模板用 webpack-simple) 本地文件夹名称
进入到生成目录里面
cd xxx
npm install
npm run dev

-------------------------------------------------------------------------------------------------------------------

路由安装

http://router.vuejs.org/zh-cn/index.html

cnpm install vue-router --save-dev

main.js配置

import VueRouter from 'vue-router'
Vue.use(VueRouter)

路由设置的JS 写在 main.js里面

例子:

import Vue from 'vue'
import App from './App.vue'
import axios from 'axios'
import VueRouter from 'vue-router'




Vue.use(VueRouter)


Vue.prototype.$http = axios


//------------------------------------------------
//路由例子
        
var Home={
   template:'<div>'+
    '<h3>我是主页</h3>'+
    '<p>哈哈</p>'+
    '</div>'
};
var News={
   template:'<h3>我是新闻</h3>'
};


//配置路由
const routes=[
   {path:'/home', component:Home},
   {path:'/news', component:News},
   {path:'*', redirect:'/home'}
];


//生成路由实例
const router=new VueRouter({
   routes
});
 //------------------------------------------------ 


new Vue({
  router,   //路由挂载
  el: '#app',
  render: h => h(App)
})

-------------------------------------------------------------------------------------------------------------------

想进行数据交互 用 axios

1 git-bash 下载  cnpm i axios --save-dev

2 打开 main.js 进行添加

import axios from 'axios'
Vue.prototype.$http = axios

-------------------------------------------------------------------------------------------------------------------


如果想网速快 可用 cnpm

1 打开git-bash

   输入   

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值