输入框输入IPv4、子网掩码格式(子网掩码输入3个数字自动跳转下一个输入框)

效果图

四个input联用

ipv4格式

html

<div class="input">
                    <a-row type="flex" justify="start">
                      <a-space>
                        <a-col :span="2"
                          ><a-space
                            ><a-input
                              ref="ip1"
                              v-model="ip.ip1"
                              @input="searchip1"
                              style="width: 50px"
                              :maxLength="3"
                            ></a-input
                            ><span>.</span></a-space
                          ></a-col
                        >
                        <a-col :span="2"
                          ><a-space
                            ><a-input
                              ref="ip2"
                              v-model="ip.ip2"
                              @input="searchip2"
                              style="width: 50px"
                              :maxLength="3"
                            ></a-input
                            ><span>.</span></a-space
                          ></a-col
                        >
                        <a-col :span="2"
                          ><a-space
                            ><a-input
                              ref="ip3"
                              v-model="ip.ip3"
                              @input="searchip3"
                              style="width: 50px"
                              :maxLength="3"
                            ></a-input
                            ><span>.</span></a-space
                          ></a-col
                        >
                        <a-col :span="2"><a-input ref="ip4" v-model="ip.ip4" :maxLength="3"></a-input></a-col> </a-space
                    ></a-row>
                  </div>

js

<script>
export default {
  data() {
return{
    ip: {
        ip1: null,
        ip2: null,
        ip3: null,
        ip4: null,
      },
      mask: {
        a1: 255,
        a2: 255,
        a3: 255,
        a4: '',
      },

}
}
methods: {
    //指定核心设备输入自动跳转
    searchip1() {
      var value = this.ip.ip1.length
      if (value == '3') {
        this.$refs.ip2.focus()
      }
    },
    searchip2() {
      var value = this.ip.ip2.length
      if (value == '3') {
        this.$refs.ip3.focus()
      }
    },
    searchip3() {
      var value = this.ip.ip3.length
      if (value == '3') {
        this.$refs.ip4.focus()
      }
    },
}
}
</script>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值