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

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

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    Vue表单回车事件下一个input获取焦点
    19
    0

    动态生成的一组input,触发enter事件后怎么focus下一个input

    <li class="border-none" v-for="(item,index) in prcHdAreaList" :key="item.pmcKeyVal">
        <input
             :ref="item.pmcKeyVal"
             v-focus-next-on-enter="'item.pmcKeyVal'" 
             name="item.phaRate" class="cus_input" 
             v-model.trim="item.phaRate" type="number"/>
    </li>
    
    Vue.directive('focusNextOnEnter', {
          bind: function(el, {value}, vnode) {
            el.addEventListener('keyup', (ev) => {
              if (ev.keyCode === 13) {
                let nextInput = vnode.context.$refs[value]
                if (nextInput && typeof nextInput.focus === 'function') {
                  nextInput.focus()
                  nextInput.select()
                }
              }
            })
         }
    })
    
    0
    打赏
    收藏
    点击回答
        全部回答
    • 0
    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部