[英]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.