Skip to content

Commit

Permalink
SvgIcon 组件支持传入本地图片
Browse files Browse the repository at this point in the history
  • Loading branch information
hooray committed Aug 12, 2024
1 parent 47513a3 commit 43b2e31
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/components/SvgIcon/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ const props = defineProps<{
}>()
const outputType = computed(() => {
if (/^https?:\/\//.test(props.name)) {
const hasPathFeatures = (str: string) => {
return /^\.{1,2}\//.test(str) || str.startsWith('/') || str.includes('/')
}
if (/^https?:\/\//.test(props.name) || hasPathFeatures(props.name)) {
return 'img'
}
else if (/i-[^:]+:[^:]+/.test(props.name)) {
Expand Down

0 comments on commit 43b2e31

Please sign in to comment.