vuetify ip输入_Vuetify国际电话输入

本文介绍了如何在Vuetify项目中使用vue-tel-input-vuetify库进行国际电话输入。通过Vue CLI创建新项目,然后安装并配置Vuetify和vue-tel-input-vuetify,提供了一个示例仓库供参考。文章还详细说明了组件的使用,包括属性和事件。
摘要由CSDN通过智能技术生成

vuetify ip输入

vue电话输入vuetify (vue-tel-input-vuetify)

International Telephone Input with Vuetify.

Vuetify的国际电话输入。

vue-tel-input-vuetify

安装 (Installation)

示例存储库 (Example Repository)

You might want to follow and use the basic example usage of this library in this repository Example

你可能想要关注和使用这个库的基本用法示例在这个仓库

OR try from scratch with below steps

或者按照以下步骤从头开始尝试

Vue-Cli (vue-cli)

  • create new vue project using vue-cli:

    使用vue-cli创建新的vue项目:

vue create my-app
  cd my-app

证明 (vuetify)

  • install vuetify to newly created vue project

    vuetify安装到新创建的vue项目

vue add vuetify

npm (npm)

  • install vue-tel-input-vuetify to newly created vue project

    vue-tel-input-vuetify安装到新创建的vue项目

npm install vue-tel-input-vuetify

Install the plugin into Vue:

将插件安装到Vue中:

With vuetify loader:

使用vuetify loader:

// src/plugins/vuetify.js

  import Vue from 'vue';
  import Vuetify from 'vuetify/lib';

  Vue.use(Vuetify);

  export default new Vuetify({
  });
// src/VueComponent.js

import VueTelInputVuetify from "vue-tel-input-vuetify/lib/vue-tel-input-vuetify.vue"

<template>
  <vue-tel-input-vuetify></vue-tel-input-vuetify>
</template>

export default {
  components: {
    VueTelInputVuetify,
  },
};
// src/main.js

import Vue from 'vue';
import vuetify from "@/plugins/vuetify";

new Vue({
  vuetify,
  render: (h) => h(App),
}).$mount("#app");

Without vuetify loader:

没有vuetify加载程序:

// src/plugins/vuetify.js

  import Vue from 'vue';
  import Vuetify from 'vuetify';
  import 'vuetify/dist/vuetify.min.css'

  Vue.use(Vuetify);

  export default new Vuetify({
  });
// src/main.js

import Vue from 'vue';
import VueTelInputVuetify from "vue-tel-input-vuetify";
import vuetify from "./plugins/vuetify";

Vue.use(VueTelInputVuetify, {
  vuetify,
});

new Vue({
  vuetify,
  render: (h) => h(App),
}).$mount("#app");

View all available options in Props.

在“ 道具”中查看所有可用选项。

Use the vue-tel-input-vuetify component:

使用vue-tel-input-vuetify组件:

<template>
  <vue-tel-input-vuetify v-model="phone"></vue-tel-input-vuetify>
<template>

<script>
export default {
  data() {
    return {
      phone: null
    }
  }
};
</script>

用法 (Usage)

道具 (Props)

PropertyTypeDefault valueDescription
messagesString | Array[]Displays a list of messages or message if using a string
success-messagesString | Array[]Puts the input in a success state and passes through custom success messages.
error-messagesString | Array[]Puts the input in an error state and passes through custom error messages. Will be combined with any validations that occur from the rules prop. This field will not trigger validation
hintStringundefinedHint text
suffixStringundefinedDisplays suffix text
prefixStringundefinedDisplays prefix text
background-colorStringundefinedChanges the background-color of the input
rulesStringArrayAccepts an array of functions that take an input value as an argument and return either true / false or a string with an error message
loader-heightNumber | String2Specifies the height of the loader
loadingString | BooleanfalseDisplays linear progress bar. Can either be a String which specifies which color is applied to the progress bar (any material color or theme color - primary, secondary, success, info, warning, error) or a Boolean which uses the component color (set by color prop - if it's supported by the component) or the primary color
hide-detailsString | BooleanundefinedHides hint and validation errors. When set to auto messages will be rendered only if there's a message (hint, error message, counter value etc) to display
clearableBooleanfalseAdd input clear functionality, default icon is Material Icons clear
filledBooleanfalseApplies the alternate filled input style
full-widthBooleanfalseDesignates input type as full-width
flatBooleanfalseRemoves elevation (shadow) added to element when using the solo or solo-inverted props
lightBooleanfalseApplies the light theme variant to the component.
validate-on-blurBooleanfalseDelays validation until blur event
outlinedBooleanfalseApplies the outlined style to the input
persistent-hintBooleanfalseForces hint to always be visible
readonlyBooleanfalsePuts input in readonly state
errorBooleanfalsePuts the input in a manual error state
successBooleanfalsePuts the input in a manual success state
shapedBooleanfalseRound if outlined and increase border-radius if filled. Must be used with either outlined or filled
single-lineBooleanfalseLabel does not move on focus/dirty
roundedBooleanfalseAdds a border radius to the input
valueany''The input's value
labelString'Enter a Phone Number'Native input 'label' attribute
autocompleteString'on'Native input 'autocomplete' attribute
autofocusBooleanfalseNative input 'autofocus' attribute
defaultCountryString''Default country, will override the country fetched from IP address of user
disabledBooleanfalseDisable input field
disabledFetchingCountryBooleanfalseDisable fetching current country based on IP address of user
ignoredCountriesArray[]List of countries will NOT be shown on the dropdown. ie ['AU', 'BR']
inputIdString''Custom 'id' for the input
inputOptionsObject{ showDialCode: false, tabindex: 0 }Options for input, supporting showDialCode (always show dial code in the input) and tabindex
maxLenNumber25Native input 'maxlength' attribute
modeString''Format number to 'international' (with + dial code) or 'national' (with 0...)
nameString'telephone'Native input 'name' attribute
onlyCountriesArray[]List of countries will be shown on the dropdown. ie ['AU', 'BR']
placeholderString'Enter a phone number'Placeholder for the input
preferredCountriesArray[]Preferred countries list, will be on top of the dropdown. ie ['AU', 'BR']
requiredBooleanfalseRequired property for HTML5 required attribute
validCharactersOnlyBooleanfalseOnly allow valid characters in a phone number (will also verify in mounted, so phone number with invalid characters will be shown as an empty string)
wrapperClassesString | Array | Object''Custom classes for the wrapper
属性 类型 默认值 描述
messages String | Array [] 显示消息列表或消息(如果使用字符串)
success-messages String | Array [] 将输入置于成功状态,并传递自定义成功消息。
error-messages String | Array [] 将输入置于错误状态并传递自定义错误消息。 将与规则属性中发生的所有验证结合在一起。 该字段不会触发验证
hint String undefined 提示文字
suffix String undefined 显示后缀文字
prefix String undefined 显示前缀文本
background-color String undefined 更改输入的背景色
rules String Array 接受将输入值作为参数的函数数组,并返回true / false或带错误消息的字符串
loader-height Number String 2 指定装载机的高度
loading String | Boolean false 显示线性进度条。 可以是指定将哪种颜色应用于进度栏的字符串(任何材料颜色或主题颜色-主,辅,成功,信息,警告,错误),也可以是使用组件颜色的布尔值(由颜色属性设置-如果是由组件支持)或原色
hide-details String | Boolean undefined 隐藏提示和验证错误。 设置为自动时,仅当有消息(提示,错误消息,计数器值等)显示时才会呈现消息
clearable Boolean false 添加输入清除功能,默认图标为“材料图标”清除
filled Boolean false 应用替代填充输入样式
full-width Boolean false 将输入类型指定为全角
flat Boolean false 当使用独奏或反转的道具时,删除添加到元素的高程(阴影)
light Boolean false 将浅色主题变体应用于组件。
validate-on-blur Boolean false 延迟验证直到模糊事件
outlined Boolean false 将轮廓样式应用于输入
persistent-hint Boolean false 强制提示始终可见
readonly Boolean false 将输入置于只读状态
error Boolean false 将输入置于手动错误状态
success Boolean false 将输入置于手动成功状态
shaped Boolean false 如果勾勒出圆角,则填满,增加边界半径。 必须与概述或填充一起使用
single-line Boolean false 标签没有移到焦点/脏处
rounded Boolean false 将边界半径添加到输入
value any '' 输入值
label String 'Enter a Phone Number' 本机输入“标签”属性
autocomplete String 'on' 本机输入“自动完成”属性
autofocus Boolean false 本机输入“自动对焦”属性
defaultCountry String '' 默认国家/地区,将覆盖从用户IP地址获取的国家/地区
disabled Boolean false 禁用输入字段
disabledFetchingCountry Boolean false 禁用基于用户的IP地址获取当前国家/地区
ignoredCountries Array [] 国家列表将不会显示在下拉列表中。 即['AU', 'BR']
inputId String '' input自定义“ id”
inputOptions Object { showDialCode: false, tabindex: 0 } 输入选项,支持showDialCode (始终在输入中显示拨号代码)和tabindex
maxLen Number 25 本机输入'maxlength'属性
mode String '' 将数字格式设置为'international' (带+拨号代码)或'national' (带0 ...)
name String 'telephone' 本机输入“名称”属性
onlyCountries Array [] 国家列表将显示在下拉列表中。 即['AU', 'BR']
placeholder String 'Enter a phone number' 输入的占位符
preferredCountries Array [] 首选国家/地区列表将位于下拉列表的顶部。 即['AU', 'BR']
required Boolean false HTML5必需属性的必需属性
validCharactersOnly Boolean false 仅允许电话号码中包含有效字符(也将在已mounted验证,因此电话号码中包含无效字符的情况将显示为空字符串)
wrapperClasses String | Array | Object '' 包装器的自定义类

大事记 (Events)

EventArgumentsDescriptionNotes
inputString, ObjectFires when the input changes with the argument is the object includes { number, isValid, country }onInput deprecated
validateObjectFires when the correctness of the phone number changes (from true to false or vice-versa) and when the component is mounted { number, isValid, country }onValidate deprecated
blurFires on blur eventonBlur deprecated
spaceFires on keyup.space eventonSpace deprecated
enterFires on keyup.enter eventonEnter deprecated
openFires when the flags dropdown opens
closeFires when the flags dropdown closes
country-changedObjectFires when country changed (even for the first time)
事件 争论 描述 笔记
input String Object 当输入随参数更改为对象包括{ number, isValid, country }时触发 不推荐使用onInput
validate Object 当电话号码的正确性更改(从“ true到“ false或从“ true到“ false ,反之亦然)并且安装了组件{ number, isValid, country }时触发 不推荐使用onValidate
blur 在模糊事件上触发 不推荐使用onBlur
space 在keyup.space事件上触发 onSpace使用onSpace
enter 在keyup.enter事件上触发 onEnter已弃用
open 当标志下拉列表打开时触发
close 当标志下拉列表关闭时触发
country-changed Object 国家变更(即使是第一次)时触发

翻译自: https://vuejsexamples.com/international-telephone-input-with-vuetify/

vuetify ip输入

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值