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({