简体   繁体   English

如何将保存的电话号码绑定到 vue tel 输入以进行编辑

[英]How can I bind saved phone number to vue tel input for the purpose of editing

I am using vue-tel-input for entering a phone number.我正在使用 vue-tel-input 输入电话号码。

Here is the code:这是代码:

<template>
<div>
   <vue-tel-input v-model="client.ClientPhone" v-bind="bindPropsUserInfo"></vue-tel-input>
</div>
</template>


<script>
  data() {
    return {
      bindPropsUserInfo: {
        mode: "international",
        autoFormat: false,
        required: true,
        enabledCountryCode: true,
        enabledFlags: true,
        autocomplete: "off",
        name: "telephone",
        maxLen: 25,
        inputOptions: {
          showDialCode: true
        }
      }
    };
  },
</script>

` `

` This is binding the value and saving it to the database. ` 这是绑定值并将其保存到数据库中。

But in the edit mode, It override the saved value with country code.但在编辑模式下,它会用国家代码覆盖保存的值。

How do I bind the saved value to the vue-tel-input?如何将保存的值绑定到 vue-tel-input?

Is there any solution for this or this behavior can't be changed?是否有解决此问题或无法更改此行为的方法?

To bind the saved phone number to the vue-tel-input for the purpose of editing, you can use the value prop provided by the vue-tel-input component.要将保存的电话号码绑定到 vue-tel-input 以进行编辑,您可以使用 vue-tel-input 组件提供的 value 属性。

First make sure that the saved phone number is stored in a property of your Vue component, such as client.首先确保保存的电话号码存储在 Vue 组件的属性中,例如 client. ClientPhone.客户电话。

<template>
  <div>
     <vue-tel-input v-model="client.ClientPhone" v-bind="bindPropsUserInfo" :value="client.ClientPhone"></vue-tel-input>
  </div>
</template>

This will bind the saved phone number to the vue-tel-input, and the vue-tel-input will automatically format the phone number based on the mode prop.这会将保存的电话号码绑定到 vue-tel-input,vue-tel-input 会根据 mode 属性自动格式化电话号码。 In this case, the phone number will be formatted as an international phone number.在这种情况下,电话号码将被格式化为国际电话号码。

If you want to prevent the vue-tel-input from overwriting the saved phone number with the country code, you can set the autoFormat prop to false.如果你想防止 vue-tel-input 用国家代码覆盖保存的电话号码,你可以将 autoFormat 属性设置为 false。 This will disable automatic formatting of the phone number, and the vue-tel-input will display the saved phone number as it is.这将禁用电话号码的自动格式化,vue-tel-input 将按原样显示保存的电话号码。

<template>
  <div>
     <vue-tel-input v-model="client.ClientPhone" v-bind="bindPropsUserInfo" :value="client.ClientPhone" :autoFormat="false"></vue-tel-input>
  </div>
</template>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从电话号码 vue-tel-input 中删除国家代码 - Remove country code from phone number vue-tel-input 在手机上使用输入类型=“ tel”时,如何更改Enter键? - When using input type=“tel” on a mobile phone, how can I change what the enter key does? 如何绑定国家更改国际电话输入 - how to bind country change intl tel input 如何使用 intl-tel-input 插件获取带有拨号代码的完整电话号码? - How to get the complete phone number with the dial code using intl-tel-input plugin? 我怎样才能将格式从文本更改为数字和电话? - how can i change format from text to number and tel? 如何在 Nuxt 中使用 vue-tel-input-vuetify? - How to use vue-tel-input-vuetify in Nuxt? 如何使用 vue Js 将对象值绑定到动态添加的输入字段 - how can I bind an object values to the dynamically added input field using vue Js 如何使用 react-phone-number-input 插入数据?,插入电话号码时出现验证错误 - How can I insert a data using react-phone-number-input?, validation error when I'm inserting a phone number 如何使用国际电话输入来格式化数字? - How to format number using intl-tel-input? 如何在不使用输入类型数字/电话的情况下在手机上显示小键盘? - How to show numpad on mobile without using input type number/tel?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM