1、在main.js导入axios
// 导入axios
import axios from 'axios'
// 挂载axios 到Vue的原型prototype的$http
Vue.prototype.$http = axios
// 设置请求的根路径
axios.defaults.baseURL = "http://localhost:9000/"
2、设置密码为不可见
3、给按钮button添加click方法
4、测试结果
5、测试弹出
login(){
this.$refs.loginFormRef.validate(async valid => {
if(!valid) return;
const{data:res}= await this.$http.post("test")
if(res =="ok")
{
this.$message.success("操作成功");
}else{
this.$message.error("操作失败")
}
})
}
6、新建一个Home.vue
<template>
<div>
Home首页
</div>
</template>
<script>
</script>
<style >
</style>
在index.js导入
import Home from '../components/Home.vue'
{
path:"/home",
component: Home
},
7、测试跳转
this.$router.push({path:"/Home"})
跳转成功