账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    vue没有点提交按钮,在input输入时就触发submit了,不知道为什么
    17
    0

    vue没有点提交按钮,在input输入时就触发submit了,不知道为什么。

    因为不想触发submit时刷新,我就加了prevent
    我是为了自己写一个自定义的表单校验指令

    相关代码
    .vue页面

    <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>
    

    以及我的自定义指令,还没写完,别介。。。

    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){}
    });
    
    
    
    0
    打赏
    收藏
    点击回答
        全部回答
    • 0
    • 北风微凉 普通会员 1楼
      502 Bad Gateway

      502 Bad Gateway


      nginx
    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部