import router from ‘./router’
import axios from ‘axios’
Vue.prototype.axios = axios
// 原生ajax、axios请求时,如果不显示的设置Content-Type,那么默认是text/plain,这时服务器就不知道怎么解析数据了,所以才只能通过获取原始数据流的方式来进行解析请求数据。
axios.defaults.headers.post[‘Content-Type’] = ‘application/x-www-form-urlencoded’
Vue.config.productionTip = false
new Vue({
router,
render: h => h(App)
}).$mount(‘#app’)
app.vue
router/index.js
import Vue from ‘vue’
import Router from ‘vue-router’
import Login from ‘@/pages/Login.vue’
import Main from ‘@/pages/Main.vue’
import Home from ‘@/pages/Home.vue’
Vue.use(Router)
export default new Router({
mode: ‘history’,
routes: [
{
path: ‘/’,
name: ‘Login’,
component: Login
}, {
path: ‘/main’,
name: ‘Main’,
component: Main
}, {
path: ‘/home’,
name: ‘Home’,
component: Home
}
]
})
pages/Home.vue
欢迎 {{name}}
<a href=“#” @click=“quit”>注销登录
pages/Login.vue
登录
{{tishi}}
登录
没有账号?马上注册
注册
{{tishi}}
注册
已有账号?马上登录