背景图片组件的封装
This commit is contained in:
parent
3f3883e908
commit
8b8b519b8e
1
components/base-background/README.md
Normal file
1
components/base-background/README.md
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
|
||||||
54
components/base-background/base-background.vue
Normal file
54
components/base-background/base-background.vue
Normal 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>
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
<view class="page">
|
<view class="page">
|
||||||
<custom-navbar title="高僧详情" />
|
<custom-navbar title="高僧详情" />
|
||||||
<image class="background-image" :src="CommonEnum.BACKGROUND" mode="aspectFill"></image>
|
<base-background />
|
||||||
<view class="container">
|
<view class="container">
|
||||||
<view class="header">
|
<view class="header">
|
||||||
<view class="content">
|
<view class="content">
|
||||||
|
|
@ -49,10 +49,12 @@ import CommonEnum from "../../enum/common";
|
||||||
import MonkEnum from "../../enum/monk";
|
import MonkEnum from "../../enum/monk";
|
||||||
import {getMonkDetail} from "../../api/monk/monkDetail.js";
|
import {getMonkDetail} from "../../api/monk/monkDetail.js";
|
||||||
import CustomNavbar from "../../components/custom-navbar/custom-navbar.vue";
|
import CustomNavbar from "../../components/custom-navbar/custom-navbar.vue";
|
||||||
|
import BaseBackground from "../../components/base-background/base-background.vue";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
CustomNavbar
|
CustomNavbar,
|
||||||
|
BaseBackground
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
MonkEnum() {
|
MonkEnum() {
|
||||||
|
|
@ -128,15 +130,7 @@ export default {
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.background-image {
|
|
||||||
position: absolute;
|
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
z-index: -1;
|
|
||||||
border-radius: 16rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.page {
|
.page {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user