You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
727 B
TypeScript

// TODO 图标按需加载
import * as AntIcons from '@ant-design/icons-vue'
import { createVNode, defineComponent } from 'vue'
const AntIcon = defineComponent({
name: 'AntIcon',
props: {
type: {
type: String,
required: true
}
},
setup(props) {
const iconDom = computed(() => {
let iconType = props.type
.replace(/-([a-z])/g, (p, m) => m.toUpperCase())
.replace(/^\S/, s => s.toUpperCase())
if (!iconType.endsWith('Outlined')) {
iconType = iconType + 'Outlined'
}
// @ts-ignore
const antIcon = AntIcons[iconType]
return antIcon ? createVNode(antIcon) : props.type
})
return () => iconDom.value
}
})
export default AntIcon