941477276 / vue3-country-intl

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

能否支持置顶某些国家? #10

Closed taozuhong closed 5 months ago

taozuhong commented 11 months ago

能否支持置顶某些国家,比如把中国、美国、日本等国家靠前显示。

感谢楼主的分享和支持。

941477276 commented 11 months ago

排序功能已增加,需更新版本至2.0.2。增加了sort属性,该属性的值需为一个函数,与Array.sort功能一致

taozuhong commented 11 months ago

支持权重值吗? 我在想排序如何实现置顶的意图呢

941477276 commented 11 months ago

2.0.3已支持该功能。你需要传递一个transform属性,你可以通过该函数对数据列表进行深度定制,如排序、过滤、置顶等;该属性值的类型需为function,且该函数必须返回处理过后的列表。

taozuhong commented 11 months ago

求分享 transform 的使用案例,谢谢。

taozuhong commented 11 months ago

还有我注意到项目没有明确的许可证,可能让大家不敢使用哦。

941477276 commented 11 months ago

求分享 transform 的使用案例,谢谢。

<template>
  <Vue3CountryIntl :transform="transform"></Vue3CountryIntl>
</template>

<script setup>
 const transform = function (countryList) {
  let newCountryList = ... // 你的排序排序逻辑
  return newCountryList
}
</script>
941477276 commented 11 months ago

还有我注意到项目没有明确的许可证,可能让大家不敢使用哦。

无需担心,本套代码使用MIT协议,后续我会把开源协议写进去