From 4a323995f9f256fc34f1e4e0032cd0c9f8e352b3 Mon Sep 17 00:00:00 2001 From: xing Date: Tue, 16 Jun 2020 15:08:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=95=E5=85=A5axios?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Login.vue | 13 ++++++++++++- src/main.js | 4 ++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/components/Login.vue b/src/components/Login.vue index cfa3c60..d9887a7 100644 --- a/src/components/Login.vue +++ b/src/components/Login.vue @@ -12,7 +12,7 @@ - 登录 + 登录 重置 @@ -42,6 +42,17 @@ export default { } }, methods: { + submit () { + this.$refs.loginFormRef.validate(async valid => { + if (!valid) { + return + } + const { data: res } = await this.$http.post('login', this.loginForm) + if (res.meta.status !== 200) { + return console.log('login fail') + } + }) + }, reset () { this.$refs.loginFormRef.resetFields() } diff --git a/src/main.js b/src/main.js index 51184c0..e404c3a 100644 --- a/src/main.js +++ b/src/main.js @@ -5,8 +5,12 @@ import ElementUI from 'element-ui' import 'element-ui/lib/theme-chalk/index.css' import './assets/fonts/iconfont.css' import './assets/css/globel.css' +import axios from 'axios' +axios.defaults.baseURL = 'http://127.0.0.1:8888/api/private/v1/' +Vue.prototype.$http = axios Vue.use(ElementUI) + Vue.config.productionTip = false new Vue({