How does Vue trigger the keyboard enter event

Insert picture description here
Writing: @keyup.enter.native="Custom Event"

<Input v-model="form.checkCode" placeholder="请输入校验码" @keyup.enter.native="searchAllCompany">
     <span slot="append">
          {
    
    {
    
     code }}
     </span>
</Input>

methods:{
    
    
	searchAllCompany(){
    
    
      console.log(123)
      this.handleSubmit()
    },
    handleSubmit() {
    
    
      
          //接口调试
          this.$axios
            .post("/api/sysAdmin/login/login", {
    
    
              loginName: this.form.userName,
              pwd: this.form.password,
            })
            .then((res) => {
    
    
              console.log(res);
              if (res.status === 200) {
    
    
                console.log("登录信息:", res);
                var data = JSON.parse(res.data.data.session_role);
                console.log(res.data.data.session_key);
                this.$store.commit("getToken", res.data.data.session_key);
                console.log(localStorage.getItem("token"));
                this.$store.commit(
                  "getUserInfo",
                  JSON.stringify(data.userInfo)
                );
                this.$router.push({
    
    
                  path: "home",
                  name: "home",
                });
                this.$Message.success("登录成功");
              } else {
    
    
                this.$Message.warning("登录失败");
              }
            });
    },
}

This will trigger the enter event directly after entering the verification code

Guess you like

Origin blog.csdn.net/GongWei_/article/details/112221280