vant-vue页面 常用的表单代码全

密码修改表单

<template>
  <div>
    <van-form @submit="onSubmit">
      <van-field
        name="originalPassword"
        v-model="originalPassword"
        type="password"
        label="原密码"
        placeholder="请输入原密码"
        required
        :rules="[{ required: true, message: '请填写原密码'}]"/>
      <van-field
        name="newPassword"
        v-model="newPassword"
        type="password"
        label="新密码"
        placeholder="请输入新密码"
        required
        :rules="[
          { required: true, message: '请填写新密码'},
          { pattern:/^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,12}$/, message: '密码必须是由6-12位字母和数字组成!'}
        ]"/>
      <van-field
        name="confirmNewPassword"
        v-model="confirmNewPassword"
        type="password"
        label="确认新密码"
        placeholder="请输入确认密码"
        required
        :rules="[{ required: true, message: '请填写确认密码'}]"/>
      <div style="margin: 16px;">
        <van-button round block type="info" native-type="submit" :loading="loading">
          提交
        </van-button>
      </div>
    </van-form>
  </div>
</template>
<script>
import {Toast, Notify} from 'vant';
import {changePassword} from "@/views/agent/admin/login/api";
export default {
  data() {
    return {
      originalPassword: '',
      newPassword: '',
      confirmNewPassword: '',
      loading: false,
    }
  },

  methods: {
    async onSubmit(values) {
      this.loading = true;
      try{
        await changePassword({ ...values})
        Notify({type: 'success', message: '修改成功,请重新登录!'});
        this.$router.replace('/agent/admin/login');
      }catch ({message}) {
        this.loading = false;
        Toast({message});
      }
    }
  }
}
</script>

特全表单

官网:(点我

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值