ycc-521

1.安装element-ui 运行命令 npm i element-ui -S

2.安装路由 运行命令   npm install vue-router

使用:在index.js中引入  

import Vue from \'vue\'
import Router from \'vue-router\'
Vue.use(Router)

路由配备:引入模块

import HelloWorld from \'../components/HelloWorld\' //登录页


export default new Router({
routes: [
{
path: \'/\',
redirect: \'login\'
},
{
path: \'/login\',
component: HelloWorld,
},
]
})
上面的写法是默认打开登录页(系统刚打开就是登录页)

2.http请求 运行命令 npm install vue-resource(相当于$.ajax)

在主页面引用:

import VueResource from \'vue-resource\'
Vue.use(VueResource)
在页面使用方式可以直接使用

this.$http.get(\'/someUrl\').then(response => {
 
    // get body data(请求到数据以后)
    cosnole.log(response.data);
 
  }response => {
    // error callback (发送请求失败)
  });

 

分类:

技术点:

相关文章: