elementui vue 前端笔记

这篇博客介绍了如何在Vue.js应用中创建一个登录界面,利用Vuex进行状态管理,包括数据绑定、表单验证和提交处理。同时,文章提到了在IDEA中遇到的数据库时区问题,通过设置`?serverTimezone=GMT`来解决。
摘要由CSDN通过智能技术生成

登录界面

语法糖

<script>
import { mapMutations } from "vuex";
 
export default {
  name: "Login",
  data: function () {
    return {
      loginForm: {
        account: "",
        passWord: "",
      },
      loginRules: {
        account: [{ required: true, message: "请输入账号", trigger: "blur" }],
        passWord: [{ required: true, message: "请输入密码", trigger: "blur" }],
      },
    };
  },
 
  methods: {
    ...mapMutations(["changeLogin"]),
    submitForm() {
      const userAccount = this.loginForm.account;
      const userPassword = this.loginForm.passWord;
      if (!userAccount) {
        return this.$message({
          type: "error",
          message: "账号不能为空!",
        });
      }
      if (!userPassword) {
        return this.$message({
          type: "error",
          message: "密码不能为空!",
        });
      }
      console.log("用户输入的账号为:", userAccount);
      console.log("用户输入的密码为:", userPassword);
    },
  },
};
</script>

mapMutations是vuex的mutation的辅助函数,用于在组件中映射mutation内的方法,以便在该组件中直接使用mutation里的方法。
import{ } from ’ ’

script methods 调取函数

:model=“ruleForm” 是要绑定的数据
:rules=“rules” 是要绑定的表单验证规则
ref=“ruleForm” 是给el-form这个组件起的名称
prop=“name” 是验证规则的属性

this.$refs.editFormRefs.resetFields()

需要ref model rule 和prop
(在ele-form-item中)

idea打开数据库时区问题

附上

?serverTimezone=GMT

即可

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值