最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

vue+iview實(shí)現(xiàn)手機(jī)號(hào)分段輸入框

 更新時(shí)間:2022年03月25日 17:09:43   作者:[暫停使用]任先陽(yáng)  
這篇文章主要為大家詳細(xì)介紹了vue+iview實(shí)現(xiàn)手機(jī)號(hào)分段輸入框,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

vue + iview 實(shí)現(xiàn)一個(gè)手機(jī)分段的提示框,知識(shí)點(diǎn)還沒(méi)總結(jié),供大家參考,具體內(nèi)容如下

<template>
? <div :class="{'ivu-form-item-error':!valid && dirty && validated}">
? ? <div class="ivu-phone-input ivu-select ?ivu-select-multiple ivu-select-default" @keydown.delete.prevent @click.stop>
? ? ? <input type="text" class="ivu-select-selection number-block"
? ? ? ? ? ? ?v-for="(item,index) in phoneLength" :key="index"
? ? ? ? ? ? ?:ref="numberRefName+index"
? ? ? ? ? ? ?@focus="handlerFocus"
? ? ? ? ? ? ?@input="handlerInput($event,index)"
? ? ? ? ? ? ?@keydown.delete.prevent="deleteNumber($event,index)"
? ? ? ? ? ? ?@keydown.left.prevent="changeInput(index - 1)"
? ? ? ? ? ? ?@keydown.right="changeInput(index + 1)"
? ? ? />
? ? ? <Icon type="ios-close-circle" class="clean-btn" @click="cleanValue"/>
? ? </div>
? </div>
</template>
?
<script>
? export default {
? ? data() {
? ? ? return {
? ? ? ? required: this.$attrs.hasOwnProperty('required'),
? ? ? ? phoneLength: 11,
? ? ? ? phoneReg: /^(13[0-9]|14[579]|15[0-3,5-9]|16[6]|17[0135678]|18[0-9]|19[89])\d{8}$/,
? ? ? ? numberRefName: 'numberBlock',
? ? ? ? validTimer: null,
? ? ? ? dirty: false,
? ? ? ? valid: false,
? ? ? ? validated: false,
? ? ? };
? ? },
? ? methods: {
?
? ? ? handlerFocus() {
? ? ? ? if (!this.dirty) {
? ? ? ? ? this.dirty = this.required ? true : false;
? ? ? ? }
? ? ? },
?
? ? ? handlerInput(e, index) {
? ? ? ? if (!e.target.value) {
? ? ? ? ? return;
? ? ? ? }
? ? ? ? this.dirty = true;
? ? ? ? let value = e.target.value.replace(/\D+/g, '');
? ? ? ? value = value ? value[0] : '';
? ? ? ? //合法值,切換下一個(gè)輸入框
? ? ? ? if (value.length) {
? ? ? ? ? this.changeInput(index + 1);
? ? ? ? }
? ? ? ? //#end
? ? ? ? e.target.value = value;
? ? ? ? this.debounceValidate();
? ? ? },
? ? ? changeInput(index) {
? ? ? ? if (index < 0 || index === this.phoneLength) return;
? ? ? ? const target = this.$refs[this.numberRefName + index][0];
? ? ? ? target.focus();
? ? ? ? if (target.value && target.setSelectionRange) {
? ? ? ? ? target.setSelectionRange(1, 1);//maxlength="1" 時(shí)無(wú)效,所以去掉了...
? ? ? ? }
? ? ? },
? ? ? deleteNumber(e, index) {
? ? ? ? if (e.target.value) {
? ? ? ? ? e.target.value = ''
? ? ? ? } else {
? ? ? ? ? this.changeInput(index - 1);
? ? ? ? }
? ? ? },
? ? ? resetStatus() {
? ? ? ? this.validated = false;
? ? ? ? this.dirty = false;
? ? ? },
? ? ? cleanValue() {
? ? ? ? this.resetStatus();
? ? ? ? const numberBlocks = this.$refs;
? ? ? ? for (let i in numberBlocks) {
? ? ? ? ? numberBlocks[i][0].value = '';
? ? ? ? }
? ? ? ? if (this.required) {
? ? ? ? ? const FormItem = this.getFormItem();
? ? ? ? ? if (FormItem) {
? ? ? ? ? ? FormItem.resetField();
? ? ? ? ? ? FormItem.$emit('on-form-change', null);
? ? ? ? ? }
? ? ? ? }
? ? ? ? // this.changeInput(0);
? ? ? },
? ? ? debounceValidate() {
? ? ? ? this.validTimer = setTimeout(() => {
? ? ? ? ? this.validate();
? ? ? ? }, 300);
? ? ? },
? ? ? validate(isLeave) {
? ? ? ? const numberBlocks = this.$refs;
? ? ? ? let result = '';
? ? ? ? for (let i in numberBlocks) {
? ? ? ? ? result += numberBlocks[i][0].value;
? ? ? ? }
? ? ? ? if (result.length === this.phoneLength || isLeave) {
? ? ? ? ? this.validated = true;
? ? ? ? ? this.dispath({
? ? ? ? ? ? value: result,
? ? ? ? ? ? valid: this.valid = this.phoneReg.test(result),
? ? ? ? ? });
? ? ? ? }
? ? ? },
? ? ? dispath(info) {
? ? ? ? this.$emit('input', info.valid ? info.value : '');
? ? ? ? if (this.required) {
? ? ? ? ? const FormItem = this.getFormItem();
? ? ? ? ? if (FormItem) {
? ? ? ? ? ? this.updateFormItem(FormItem, info.valid ? info.value : '');
? ? ? ? ? }
? ? ? ? }
? ? ? },
? ? ? getFormItem() {
? ? ? ? let MAX_LEVEL = 3;
? ? ? ? let parent = this.$parent;
? ? ? ? let name = parent.$options.name;
? ? ? ? while (MAX_LEVEL && name !== 'FormItem') {
? ? ? ? ? MAX_LEVEL--;
? ? ? ? ? if (!parent) return null;
? ? ? ? ? parent = parent.$parent;
? ? ? ? }
? ? ? ? return parent || null;
? ? ? },
? ? ? updateFormItem(FormItem, data) {
? ? ? ? FormItem.$emit('on-form-change', data);
? ? ? },
? ? ? pageEvent() {
? ? ? ? if (this.dirty) {
? ? ? ? ? this.validate(true);
? ? ? ? }
? ? ? },
? ? },
? ? created() {
? ? ? window.addEventListener('click', this.pageEvent);
? ? },
? ? beforeDestroy() {
? ? ? window.removeEventListener('click', this.pageEvent);
? ? },
? };
</script>
?
<style scoped lang="less">
? .ivu-phone-input {
? ? .clean-btn {
? ? ? transition: opacity .5s;
? ? ? opacity: 0;
? ? ? cursor: pointer;
? ? }
? ? &:hover {
? ? ? .clean-btn {
? ? ? ? opacity: 1;
? ? ? }
? ? }
? }
?
? .number-block {
? ? display: inline-block;
? ? padding: 0;
? ? height: 30px;
? ? width: 28px;
? ? text-align: center;
? ? margin-right: 2px;
? ? &:nth-child(3) {
? ? ? margin-right: 10px;
? ? }
? ? &:nth-child(7) {
? ? ? margin-right: 10px;
? ? }
? }
</style>

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • vue3使用axios并封裝axios請(qǐng)求的詳細(xì)步驟

    vue3使用axios并封裝axios請(qǐng)求的詳細(xì)步驟

    本篇文章分步驟給大家介紹了vue3使用axios并封裝axios請(qǐng)求的詳細(xì)步驟,結(jié)合實(shí)例代碼給大家講解的非常詳細(xì),需要的朋友參考下吧
    2023-06-06
  • 詳解服務(wù)端預(yù)渲染之Nuxt(介紹篇)

    詳解服務(wù)端預(yù)渲染之Nuxt(介紹篇)

    這篇文章主要介紹了詳解服務(wù)端預(yù)渲染之Nuxt(介紹篇),小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2019-04-04
  • vue如何截取字符串

    vue如何截取字符串

    這篇文章主要介紹了vue如何截取字符串,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2019-05-05
  • 高頻率Vue面試題匯總以及答案

    高頻率Vue面試題匯總以及答案

    vue是組件化開(kāi)發(fā)框架,所以對(duì)于vue應(yīng)用來(lái)說(shuō)組件間的數(shù)據(jù)通信非常重要,下面這篇文章主要給大家介紹了關(guān)于高頻率Vue面試題以及答案的相關(guān)資料,需要的朋友可以參考下
    2023-02-02
  • vue debug 二種方法

    vue debug 二種方法

    這篇文章主要介紹了vue debug 二種方法,非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2018-09-09
  • vue-cli webpack 引入jquery的方法

    vue-cli webpack 引入jquery的方法

    小編使用的是webpack模板在vue-cli生成的工程中引入jquery的方法,首先在package.json里的dependencies加入"jquery" : "^2.2.3",然后install,具體內(nèi)容詳情大家參考下本文
    2018-01-01
  • 圖片預(yù)覽插件vue-photo-preview的使用示例詳解

    圖片預(yù)覽插件vue-photo-preview的使用示例詳解

    這篇文章主要介紹了圖片預(yù)覽插件vue-photo-preview的使用,本文通過(guò)示例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2023-08-08
  • elementUI select組件value值注意事項(xiàng)詳解

    elementUI select組件value值注意事項(xiàng)詳解

    這篇文章主要介紹了elementUI select組件value值注意事項(xiàng)詳解,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2019-05-05
  • vue項(xiàng)目使用.env文件配置全局環(huán)境變量的方法

    vue項(xiàng)目使用.env文件配置全局環(huán)境變量的方法

    這篇文章主要介紹了vue項(xiàng)目使用.env文件配置全局環(huán)境變量的方法,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2019-10-10
  • Vue父子組件屬性傳遞實(shí)現(xiàn)方法詳解

    Vue父子組件屬性傳遞實(shí)現(xiàn)方法詳解

    這篇文章主要介紹了Vue父子組件屬性傳遞實(shí)現(xiàn)方法,我們主要從案例出發(fā),用Vue3的寫(xiě)法寫(xiě)父子組件之間的屬性傳遞,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧
    2023-02-02

最新評(píng)論

天津市| 丰宁| 郎溪县| 通江县| 封开县| 定陶县| 绥化市| 乐业县| 武宁县| 伊宁县| 视频| 高唐县| 兰州市| 汉川市| 博罗县| 东兴市| 民丰县| 临海市| 五寨县| 黄骅市| 鄂温| 吴旗县| 阿合奇县| 冀州市| 江源县| 宁波市| 东源县| 都江堰市| 麻城市| 兴城市| 基隆市| 贵州省| 安化县| 白银市| 刚察县| 平凉市| 廊坊市| 石城县| 六枝特区| 柯坪县| 绍兴市|