chore: 初始化项目仓库
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
<script setup lang="ts">
|
||||
const props = defineProps<{
|
||||
src?: string
|
||||
alt?: string
|
||||
}>()
|
||||
|
||||
const route = useRoute()
|
||||
|
||||
const resolvedSrc = computed(() => {
|
||||
if (!props.src) return ''
|
||||
// 绝对路径直接用
|
||||
if (props.src.startsWith('/') || props.src.startsWith('http')) return props.src
|
||||
// 相对路径:基于当前路由拼接
|
||||
const base = route.path.replace(/\/$/, '')
|
||||
return `${base}/${props.src}`
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<img :src="resolvedSrc" :alt="alt" loading="lazy" decoding="async" />
|
||||
</template>
|
||||
Reference in New Issue
Block a user