vue3 ts + Ant Design 的Select的使用
发布时间:2024年01月11日
<script setup lang="ts">
import type { SelectProps } from 'ant-design-vue'
import type { SelectValue } from 'ant-design-vue/es/select'
let searchGoodShop = ref<string | unknown>('请选择店铺')
const goodShopList = ref<SelectProps['options']>([])
const getGoodShopList = async (params: { Authorization: unknown }) => {
try {
let { data } = await goodsApi.getShopList(params)
if (data.code === 0) {
goodShopList.value = data?.data?.list.map((item: { [propName: string]: any }) => {
return {
label: item.shop_name,
value: item.authorize_id,
}
})
} else {
message.error(data.msg)
}
} catch (error) {
message.error('网络连接失败~')
}
}
const selectGoodShop = (selectValue: unknown) => {
searchGoodShop.value = selectValue
}
const reset = () => {
searchGoodShop.value = '请选择店铺'
}
</script>
<template>
<a-select
style="width: 150px; margin-right: 10px"
:value="(searchGoodShop as SelectValue)"
allowClear
show-search
@change="selectGoodShop"
>
<a-select-option v-for="(item, index) in goodShopList" :key="index" :value="item.value">
{{ item.label }}
</a-select-option>
</a-select>
<a-button @click="reset">重置</a-button>
</template>
文章来源:https://blog.csdn.net/pig_ning/article/details/135529428
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若内容造成侵权/违法违规/事实不符,请联系我的编程经验分享网邮箱:chenni525@qq.com进行投诉反馈,一经查实,立即删除!