背景图片组件的封装

This commit is contained in:
minimaxagent1 2025-07-31 14:42:22 +08:00
parent 3f3883e908
commit 8b8b519b8e
3 changed files with 60 additions and 11 deletions

View File

@ -0,0 +1 @@

View File

@ -0,0 +1,54 @@
<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>

View File

@ -1,7 +1,7 @@
<template>
<view class="page">
<custom-navbar title="高僧详情" />
<image class="background-image" :src="CommonEnum.BACKGROUND" mode="aspectFill"></image>
<base-background />
<view class="container">
<view class="header">
<view class="content">
@ -49,10 +49,12 @@ import CommonEnum from "../../enum/common";
import MonkEnum from "../../enum/monk";
import {getMonkDetail} from "../../api/monk/monkDetail.js";
import CustomNavbar from "../../components/custom-navbar/custom-navbar.vue";
import BaseBackground from "../../components/base-background/base-background.vue";
export default {
components: {
CustomNavbar
CustomNavbar,
BaseBackground
},
computed: {
MonkEnum() {
@ -128,15 +130,7 @@ export default {
</script>
<style lang="scss" scoped>
.background-image {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: -1;
border-radius: 16rpx;
}
.page {
width: 100%;