941477276 / vue3-country-intl

基于vue3的国际化的国籍/手机区号组件!
30 stars 3 forks source link

国家显示问题 #6

Closed shallow-time closed 1 year ago

shallow-time commented 1 year ago

目前type为country,选择国家时,value只能是国家代码,能不能换成国家英文名或者国家简写

941477276 commented 1 year ago

你可以通过onChange事件取到完整的国籍信息的

shallow-time commented 1 year ago

但是数据回显的话,只支持国家代码才能回显

941477276 commented 1 year ago

国家代码也能正确回显国家名称的,你用的是哪种模式?你想要的是什么效果?

shallow-time commented 1 year ago

国家代码也能正确回显国家名称的,你用的是哪种模式?你想要的是什么效果?

country 模式,我想要实现:选中国家,显示的的是国家英文名称,或者国家简写,而不是国家代码。编辑的时候可以根据国家英文名称或者国家简写回显。

shallow-time commented 1 year ago

国家代码也能正确回显国家名称的,你用的是哪种模式?你想要的是什么效果?

还有个问题,type为phone是,我设置默认值为1,显示的却是canada,而不是United States,我通过onChange打印发现他们两的dialCode字段都是1,请问如果我要设置默认号码为United States如何设置。 image

941477276 commented 1 year ago
<template>
  <VueCountryIntl type="country" v-model="country" no-data-text="没有找到相关数据"></VueCountryIntl>
</template>

<script setup>
  import { ref } from 'vue';

  let country = ref('cn');
</script>

设置type=country就可以呀

shallow-time commented 1 year ago
<template>
  <VueCountryIntl type="country" v-model="country" no-data-text="没有找到相关数据"></VueCountryIntl>
</template>

<script setup>
  import { ref } from 'vue';

  let country = ref('cn');
</script>

设置type=country就可以呀

你这个country为cn只是国家代码,展示给用户看别人是看不懂的,别人一般都是看国家英文名称,或者简写,而不是国家代码。我看到通过onChange中name字段可以获取到国家英文名称,但是回显的时候回显不了

941477276 commented 1 year ago

国家代码也能正确回显国家名称的,你用的是哪种模式?你想要的是什么效果?

还有个问题,type为phone是,我设置默认值为1,显示的却是canada,而不是United States,我通过onChange打印发现他们两的dialCode字段都是1,请问如果我要设置默认号码为United States如何设置。 image

设置iso2prop,值为国籍代码。如果未传递iso2,当多个国家的区号是一样时优先取查找到的第一个国家的区号

941477276 commented 1 year ago
<template>
  <VueCountryIntl type="country" v-model="country" no-data-text="没有找到相关数据"></VueCountryIntl>
</template>

<script setup>
  import { ref } from 'vue';

  let country = ref('cn');
</script>

设置type=country就可以呀

你这个country为cn只是国家代码,展示给用户看别人是看不懂的,别人一般都是看国家英文名称,或者简写,而不是国家代码。我看到通过onChange中name字段可以获取到国家英文名称,但是回显的时候回显不了

你用的是scheme = popover模式吗?

shallow-time commented 1 year ago
<template>
  <VueCountryIntl type="country" v-model="country" no-data-text="没有找到相关数据"></VueCountryIntl>
</template>

<script setup>
  import { ref } from 'vue';

  let country = ref('cn');
</script>

设置type=country就可以呀

你这个country为cn只是国家代码,展示给用户看别人是看不懂的,别人一般都是看国家英文名称,或者简写,而不是国家代码。我看到通过onChange中name字段可以获取到国家英文名称,但是回显的时候回显不了

你用的是scheme = popover模式吗?

scheme = input 模式:<Vue3CountryIntl @onChange="getCountry" type="country" v-model="addProviderForm.country"/>

941477276 commented 1 year ago
<template>
  <VueCountryIntl type="country" v-model="country" no-data-text="没有找到相关数据"></VueCountryIntl>
</template>

<script setup>
  import { ref } from 'vue';

  let country = ref('cn');
</script>

设置type=country就可以呀

你这个country为cn只是国家代码,展示给用户看别人是看不懂的,别人一般都是看国家英文名称,或者简写,而不是国家代码。我看到通过onChange中name字段可以获取到国家英文名称,但是回显的时候回显不了

你用的是scheme = popover模式吗?

scheme = input 模式:<Vue3CountryIntl @onchange="getCountry" type="country" v-model="addProviderForm.country"/>

image scheme = input 模式默认就可以回显的呀,要不你录个视频,然后再贴下你的代码

shallow-time commented 1 year ago
<template>
  <VueCountryIntl type="country" v-model="country" no-data-text="没有找到相关数据"></VueCountryIntl>
</template>

<script setup>
  import { ref } from 'vue';

  let country = ref('cn');
</script>

设置type=country就可以呀

你这个country为cn只是国家代码,展示给用户看别人是看不懂的,别人一般都是看国家英文名称,或者简写,而不是国家代码。我看到通过onChange中name字段可以获取到国家英文名称,但是回显的时候回显不了

你用的是scheme = popover模式吗?

scheme = input 模式:<Vue3CountryIntl @onchange="getCountry" type="country" v-model="addProviderForm.country"/>

image scheme = input 模式默认就可以回显的呀,要不你录个视频,然后再贴下你的代码

941477276 commented 1 year ago
<template>
  <VueCountryIntl type="country" v-model="country" no-data-text="没有找到相关数据"></VueCountryIntl>
</template>

<script setup>
  import { ref } from 'vue';

  let country = ref('cn');
</script>

设置type=country就可以呀

你这个country为cn只是国家代码,展示给用户看别人是看不懂的,别人一般都是看国家英文名称,或者简写,而不是国家代码。我看到通过onChange中name字段可以获取到国家英文名称,但是回显的时候回显不了

你用的是scheme = popover模式吗?

scheme = input 模式:<Vue3CountryIntl @onchange="getCountry" type="country" v-model="addProviderForm.country"/>

image scheme = input 模式默认就可以回显的呀,要不你录个视频,然后再贴下你的代码

addProviderForm .countryus的时候能正确回显不是你要的效果么?还是说name你在其他地方需要用到?

shallow-time commented 1 year ago

国家代码也能正确回显国家名称的,你用的是哪种模式?你想要的是什么效果?

还有个问题,type为phone是,我设置默认值为1,显示的却是canada,而不是United States,我通过onChange打印发现他们两的dialCode字段都是1,请问如果我要设置默认号码为United States如何设置。 image

设置iso2prop,值为国籍代码。如果未传递iso2,当多个国家的区号是一样时优先取查找到的第一个国家的区号

能否提供一个传递‘iso2’的demo

shallow-time commented 1 year ago
<template>
  <VueCountryIntl type="country" v-model="country" no-data-text="没有找到相关数据"></VueCountryIntl>
</template>

<script setup>
  import { ref } from 'vue';

  let country = ref('cn');
</script>

设置type=country就可以呀

你这个country为cn只是国家代码,展示给用户看别人是看不懂的,别人一般都是看国家英文名称,或者简写,而不是国家代码。我看到通过onChange中name字段可以获取到国家英文名称,但是回显的时候回显不了

你用的是scheme = popover模式吗?

scheme = input 模式:<Vue3CountryIntl @onchange="getCountry" type="country" v-model="addProviderForm.country"/>

image scheme = input 模式默认就可以回显的呀,要不你录个视频,然后再贴下你的代码

addProviderForm .countryus的时候能正确回显不是你要的效果么?还是说name你在其他地方需要用到?

我想要实现,country: 'United States',也能回显,因为用户想看的是你国家名字,一般看的是'United States',而不是‘us’ 。 image

941477276 commented 1 year ago

国家代码也能正确回显国家名称的,你用的是哪种模式?你想要的是什么效果?

还有个问题,type为phone是,我设置默认值为1,显示的却是canada,而不是United States,我通过onChange打印发现他们两的dialCode字段都是1,请问如果我要设置默认号码为United States如何设置。 image

设置iso2prop,值为国籍代码。如果未传递iso2,当多个国家的区号是一样时优先取查找到的第一个国家的区号

能否提供一个传递‘iso2’的demo

<template>
        <Vue3CountryIntl @onchange="getCountry" type="country" :iso2="iso2" v-model="country" @onChange="onChange" />
</template>
<script setup>
        import { ref } from 'vue';
        let iso2 = ref('');
        let country = ref('');
        let onChange = function (countryInfo) {
          iso2.value = countryInfo.iso2
        }
</script>
941477276 commented 1 year ago
<template>
  <VueCountryIntl type="country" v-model="country" no-data-text="没有找到相关数据"></VueCountryIntl>
</template>

<script setup>
  import { ref } from 'vue';

  let country = ref('cn');
</script>

设置type=country就可以呀

你这个country为cn只是国家代码,展示给用户看别人是看不懂的,别人一般都是看国家英文名称,或者简写,而不是国家代码。我看到通过onChange中name字段可以获取到国家英文名称,但是回显的时候回显不了

你用的是scheme = popover模式吗?

scheme = input 模式:<Vue3CountryIntl @onchange="getCountry" type="country" v-model="addProviderForm.country"/>

image scheme = input 模式默认就可以回显的呀,要不你录个视频,然后再贴下你的代码

addProviderForm .countryus的时候能正确回显不是你要的效果么?还是说name你在其他地方需要用到?

我想要实现,country: 'United States',也能回显,因为用户想看的是你国家名字,一般看的是'United States',而不是‘us’ 。 image

image 这样不是你想要的?

shallow-time commented 1 year ago

对,我希望可以自定义节点,可以参考antv的select组件的fieldNames设置。 image

shallow-time commented 1 year ago

国家代码也能正确回显国家名称的,你用的是哪种模式?你想要的是什么效果?

还有个问题,type为phone是,我设置默认值为1,显示的却是canada,而不是United States,我通过onChange打印发现他们两的dialCode字段都是1,请问如果我要设置默认号码为United States如何设置。 image

设置iso2prop,值为国籍代码。如果未传递iso2,当多个国家的区号是一样时优先取查找到的第一个国家的区号

能否提供一个传递‘iso2’的demo

<template>
        <Vue3CountryIntl @onchange="getCountry" type="country" :iso2="iso2" v-model="country" @onChange="onChange" />
</template>
<script setup>
        import { ref } from 'vue';
        let iso2 = ref('');
        let country = ref('');
        let onChange = function (countryInfo) {
          iso2.value = countryInfo.iso2
        }
</script>
<template>
        <Vue3CountryIntl @onchange="getCountry" type="country" :iso2="iso2" v-model="country" @onChange="onChange" />
</template>
<script setup>
        import { ref } from 'vue';
        let iso2 = ref('us'); // 我默认为us,但是显示不出来
        let country = ref('');
        let onChange = function (countryInfo) {
          iso2.value = countryInfo.iso2
        }
</script>

image

941477276 commented 1 year ago

国家代码也能正确回显国家名称的,你用的是哪种模式?你想要的是什么效果?

还有个问题,type为phone是,我设置默认值为1,显示的却是canada,而不是United States,我通过onChange打印发现他们两的dialCode字段都是1,请问如果我要设置默认号码为United States如何设置。 image

设置iso2prop,值为国籍代码。如果未传递iso2,当多个国家的区号是一样时优先取查找到的第一个国家的区号

能否提供一个传递‘iso2’的demo

<template>
        <Vue3CountryIntl @onchange="getCountry" type="country" :iso2="iso2" v-model="country" @onChange="onChange" />
</template>
<script setup>
        import { ref } from 'vue';
        let iso2 = ref('');
        let country = ref('');
        let onChange = function (countryInfo) {
          iso2.value = countryInfo.iso2
        }
</script>
<template>
        <Vue3CountryIntl @onchange="getCountry" type="country" :iso2="iso2" v-model="country" @onChange="onChange" />
</template>
<script setup>
        import { ref } from 'vue';
        let iso2 = ref('us'); // 我默认为us,但是显示不出来
        let country = ref('');
        let onChange = function (countryInfo) {
          iso2.value = countryInfo.iso2
        }
</script>

image

country没有值,肯定显示不出来

941477276 commented 1 year ago

对,我希望可以自定义节点,可以参考antv的select组件的fieldNames设置。 image

自定义节点功能暂不支持,我可以提供一个函数给你根据国籍代码或国籍区号去查询国籍信息

shallow-time commented 1 year ago

国家代码也能正确回显国家名称的,你用的是哪种模式?你想要的是什么效果?

还有个问题,type为phone是,我设置默认值为1,显示的却是canada,而不是United States,我通过onChange打印发现他们两的dialCode字段都是1,请问如果我要设置默认号码为United States如何设置。 image

设置iso2prop,值为国籍代码。如果未传递iso2,当多个国家的区号是一样时优先取查找到的第一个国家的区号

能否提供一个传递‘iso2’的demo

<template>
        <Vue3CountryIntl @onchange="getCountry" type="country" :iso2="iso2" v-model="country" @onChange="onChange" />
</template>
<script setup>
        import { ref } from 'vue';
        let iso2 = ref('');
        let country = ref('');
        let onChange = function (countryInfo) {
          iso2.value = countryInfo.iso2
        }
</script>
<template>
        <Vue3CountryIntl @onchange="getCountry" type="country" :iso2="iso2" v-model="country" @onChange="onChange" />
</template>
<script setup>
        import { ref } from 'vue';
        let iso2 = ref('us'); // 我默认为us,但是显示不出来
        let country = ref('');
        let onChange = function (countryInfo) {
          iso2.value = countryInfo.iso2
        }
</script>

image

country没有值,肯定显示不出来

<template>
        <Vue3CountryIntl @onchange="getCountry" type="phone" :iso2="iso2" v-model="country" @onChange="onChange" />
</template>
<script setup>
        import { ref } from 'vue';
        let iso2 = ref('us'); // 我默认为us,但是显示不出来
        let country = ref('+1'); // type: 为phone,country 设置的是:+1
        let onChange = function (countryInfo) {
          iso2.value = countryInfo.iso2
        }
</script>

image

shallow-time commented 1 year ago

对,我希望可以自定义节点,可以参考antv的select组件的fieldNames设置。 image

自定义节点功能暂不支持,我可以提供一个函数给你根据国籍代码或国籍区号去查询国籍信息

可以

shallow-time commented 1 year ago

国家代码也能正确回显国家名称的,你用的是哪种模式?你想要的是什么效果?

还有个问题,type为phone是,我设置默认值为1,显示的却是canada,而不是United States,我通过onChange打印发现他们两的dialCode字段都是1,请问如果我要设置默认号码为United States如何设置。 image

设置iso2prop,值为国籍代码。如果未传递iso2,当多个国家的区号是一样时优先取查找到的第一个国家的区号

能否提供一个传递‘iso2’的demo

<template>
        <Vue3CountryIntl @onchange="getCountry" type="country" :iso2="iso2" v-model="country" @onChange="onChange" />
</template>
<script setup>
        import { ref } from 'vue';
        let iso2 = ref('');
        let country = ref('');
        let onChange = function (countryInfo) {
          iso2.value = countryInfo.iso2
        }
</script>
<template>
        <Vue3CountryIntl @onchange="getCountry" type="country" :iso2="iso2" v-model="country" @onChange="onChange" />
</template>
<script setup>
        import { ref } from 'vue';
        let iso2 = ref('us'); // 我默认为us,但是显示不出来
        let country = ref('');
        let onChange = function (countryInfo) {
          iso2.value = countryInfo.iso2
        }
</script>

image

country没有值,肯定显示不出来

<template>
        <Vue3CountryIntl @onchange="getCountry" type="phone" :iso2="iso2" v-model="country" @onChange="onChange" />
</template>
<script setup>
        import { ref } from 'vue';
        let iso2 = ref('us'); // 我默认为us,但是显示不出来
        let country = ref('+1'); // type: 为phone,country 设置的是:+1
        let onChange = function (countryInfo) {
          iso2.value = countryInfo.iso2
        }
</script>

image

type为phone,iso2和绑定的数据都设置了默认值,但是控件没有显示默认数据

941477276 commented 1 year ago

国家代码也能正确回显国家名称的,你用的是哪种模式?你想要的是什么效果?

还有个问题,type为phone是,我设置默认值为1,显示的却是canada,而不是United States,我通过onChange打印发现他们两的dialCode字段都是1,请问如果我要设置默认号码为United States如何设置。 image

设置iso2prop,值为国籍代码。如果未传递iso2,当多个国家的区号是一样时优先取查找到的第一个国家的区号

能否提供一个传递‘iso2’的demo

<template>
        <Vue3CountryIntl @onchange="getCountry" type="country" :iso2="iso2" v-model="country" @onChange="onChange" />
</template>
<script setup>
        import { ref } from 'vue';
        let iso2 = ref('');
        let country = ref('');
        let onChange = function (countryInfo) {
          iso2.value = countryInfo.iso2
        }
</script>
<template>
        <Vue3CountryIntl @onchange="getCountry" type="country" :iso2="iso2" v-model="country" @onChange="onChange" />
</template>
<script setup>
        import { ref } from 'vue';
        let iso2 = ref('us'); // 我默认为us,但是显示不出来
        let country = ref('');
        let onChange = function (countryInfo) {
          iso2.value = countryInfo.iso2
        }
</script>

image

country没有值,肯定显示不出来

<template>
        <Vue3CountryIntl @onchange="getCountry" type="phone" :iso2="iso2" v-model="country" @onChange="onChange" />
</template>
<script setup>
        import { ref } from 'vue';
        let iso2 = ref('us'); // 我默认为us,但是显示不出来
        let country = ref('+1'); // type: 为phone,country 设置的是:+1
        let onChange = function (countryInfo) {
          iso2.value = countryInfo.iso2
        }
</script>

image

type为phone,iso2和绑定的数据都设置了默认值,但是控件没有显示默认数据

问题解决了,更新到1.0.16版本即可,增加了一个getCountryInfo函数可以获取国籍信息