引入axios
This commit is contained in:
parent
2d4abadfa8
commit
4a323995f9
@ -12,7 +12,7 @@
|
||||
<el-input v-model="loginForm.password" type="password" prefix-icon="iconfont icon-3702mima"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item class="btns">
|
||||
<el-button type="primary">登录</el-button>
|
||||
<el-button @click="submit" type="primary">登录</el-button>
|
||||
<el-button @click="reset" type="info">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
@ -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()
|
||||
}
|
||||
|
@ -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({
|
||||
|
Loading…
Reference in New Issue
Block a user