Vue does not click the submit button. Submit is triggered when input is typed. I don't know why.

vue does not click the submit button and triggers submit when input is typed. I don"t know why.

because I don"t want to refresh when submit is triggered, I add prevent
I write a custom form verification instruction for myself

related code
.vue page

<template>
  <div>
    1_1
    <form novalidate @submit.stop.prevent.self v-submit="dosubmit()" >
      <input type="text" v-model="a" name="a" required minlength="2" maxlength="6" pattern="/^\d*$/" />
      <input type="submit" value="" />
    </form>
  </div>
</template>

<script>
export default {
  name: "caidan1_1",
  data () {
    return {
      a:""
    }
  },
  methods:{
    dosubmit:function(){
      debugger
      console.log(this.a);
    }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>

</style>

and my custom instructions, I haven"t finished yet. Please don"t.

import Vue from "vue";
const types=["checkbox","color","date","datetime","datetime-local","month","week","time","email","file","hidden","number","password","radio","range","search","tel","text","url"];
Vue.directive("submit",{
    bind:function(el,binding,vnode,oldVnode){
        
    },
    inserted:function(el,binding,vnode,oldVnode){
        debugger
        el.addEventListener("submit",function(){
            scope[fn.replace(/\(.*\)/,"")]();
        });
        const scope=vnode.context;
        const fn=binding.expression;
        const vModelList=[];
    },
    update:function(el,binding,vnode,oldVnode){},
    componentUpdated:function(el,binding,vnode,oldVnode){},
    unbind:function(el,binding,vnode,oldVnode){}
});


May.07,2021

I won't have this problem if I remove vmursubmit= "dosubmit ()". It's probably because there's something wrong with my instructions. I'll see for myself.

v dosubmit submitt = "dosubmit", you can't bring (), drunk, @ click can bring it. It's strange. If that's the case, it won't work if you want to bring parameters to submit

Menu