vue获取form表单的值示例

这里使用的是Element-ui组件 html: <el-input placeholder="请输入手机号" id="phone" prop="phone" v-model="phone" clearable></el-input> JS: var phone = this.phone; var...

这里使用的是Element-ui组件

html:

<el-input placeholder="请输入手机号" id="phone" prop="phone" v-model="phone" clearable></el-input>

JS:

var phone = this.phone;
var password = this.password;

var that = this;
 var phone = that .phone;
 var password = that .password;
this.$axios({
  method:'post',
  url:'api/user/logout',
  data:this.qs.stringify({phone:phone,password:password})
 }).then((res) =>{   //这里使用了ES6的语法
  if (res.data.status==200){
   alert(res.data.message);
   this.$emit('userSignIn', ''); //记录登录状态
   this.$router.replace({path: '/login'}); //成功后跳转
  }
 }).catch((error) =>{
  alert(error.data.message)  //请求失败返回的数据
 })

你可能感兴趣的文章

相关问题

0 条评论

请先 登录 后评论
粪斗
粪斗

185 篇文章

作家榜 »

  1. admin 651 文章
  2. 粪斗 185 文章
  3. 王凯 92 文章
  4. 廖雪 78 文章
  5. 牟雪峰 12 文章
  6. 李沁雪 9 文章
  7. 全易 2 文章
  8. Stevengring 0 文章