buddhism/components/base-background/base-background.vue

50 lines
1.0 KiB
Vue
Raw Normal View History

2025-07-31 14:42:22 +08:00
<template>
2025-08-14 11:22:53 +08:00
<image class="background-image" :src="backgroundSrc" :mode="mode" :style="customStyle"></image>
2025-07-31 14:42:22 +08:00
</template>
<script>
2025-08-14 11:22:53 +08:00
import CommonEnum from '../../enum/common'
2025-07-31 14:42:22 +08:00
2025-08-14 11:22:53 +08:00
export default {
name: 'BaseBackground',
props: {
// 背景图片源,如果不传则使用默认背景
src: {
type: String,
default: '',
},
// 图片裁剪模式
mode: {
type: String,
default: 'aspectFill',
},
// 自定义样式
customStyle: {
type: Object,
default: () => ({}),
},
2025-07-31 14:42:22 +08:00
},
2025-08-14 11:22:53 +08:00
computed: {
CommonEnum() {
return CommonEnum
},
// 背景图片源优先使用传入的src否则使用默认背景
backgroundSrc() {
return this.src || CommonEnum.BACKGROUND
},
2025-07-31 14:42:22 +08:00
},
}
</script>
<style lang="scss" scoped>
2025-08-14 11:22:53 +08:00
.background-image {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: -1;
border-radius: 16rpx;
}
</style>