buddhism/components/base-background/base-background.vue
2025-07-31 14:42:22 +08:00

54 lines
963 B
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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