login.vue 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <template>
  2. <div class="body">
  3. <uni-forms ref="form" label-position="top" :rules="rules" :model="form">
  4. <uni-forms-item label="账号" name="account" clearable>
  5. <uni-easyinput v-model="form.account" placeholder="请输入账号"></uni-easyinput>
  6. </uni-forms-item>
  7. <uni-forms-item label="密码" name="password">
  8. <uni-easyinput v-model="form.password" type="password" placeholder="请输入密码"></uni-easyinput>
  9. </uni-forms-item>
  10. </uni-forms>
  11. <button class="login-BT" type="default" @click="submit">登录</button>
  12. </div>
  13. </template>
  14. <script>
  15. export default {
  16. data() {
  17. return {
  18. rules:{
  19. account:{
  20. rules:[
  21. {
  22. required: true,
  23. errorMessage: '请填写账号'
  24. }
  25. ],
  26. validateTrigger:'submit'
  27. },
  28. password:{
  29. rules:[
  30. {
  31. required: true,
  32. errorMessage: '请填写密码',
  33. },
  34. {
  35. minLength: 3,
  36. maxLength: 6,
  37. errorMessage: '{label}长度在 {minLength} 到 {maxLength} 个字符',
  38. },
  39. ],
  40. validateTrigger:'submit'
  41. }
  42. },
  43. form:{
  44. account:"",
  45. password:""
  46. }
  47. }
  48. },
  49. methods: {
  50. submit(){
  51. this.$refs.form.validate().then(res=>{
  52. console.log('表单数据信息:', res);
  53. }).catch(err =>{
  54. console.log('表单错误信息:', err);
  55. })
  56. }
  57. }
  58. }
  59. </script>
  60. <style lang="scss" scoped>
  61. .body{
  62. padding:224upx 90upx 0;
  63. .login-BT{
  64. margin-top:110upx;
  65. background: #8DA6FF;
  66. border-radius: 6px;
  67. color: #fff;
  68. }
  69. }
  70. </style>