【功能修复】修复标题栏装修背景图片问题

pull/76/head
卢越 2024-08-12 13:06:35 +08:00
parent 34274cbaa8
commit be5db900a0
1 changed files with 93 additions and 84 deletions

View File

@ -1,10 +1,6 @@
<!-- 装修商品组件标题栏 -->
<template>
<view
class="ss-title-wrap ss-flex ss-col-center"
:class="[state.typeMap[data.textAlign]]"
:style="[elStyles]"
>
<view class="ss-title-wrap ss-flex ss-col-center" :class="[state.typeMap[data.textAlign]]" :style="[bgStyle, { marginLeft: `${data.space}px` }]">
<view class="title-content">
<!-- 主标题 -->
<view v-if="data.title" class="title-text" :style="[titleStyles]">{{ data.title }}</view>
@ -24,7 +20,10 @@
/**
* 标题栏
*/
import { reactive } from 'vue';
import {
reactive,
computed
} from 'vue';
import sheep from '@/sheep';
//
@ -37,22 +36,32 @@
//
const props = defineProps({
//
data: {
type: Object,
default() {},
default: () => ({}),
},
//
styles: {
type: Object,
default() {},
default: () => ({}),
},
});
//
const bgStyle = computed(() => {
console.log(props.data)
// props.styles
const {
bgType,
bgImg,
bgColor
} = props.styles;
//
const elStyles = {
background: `url(${sheep.$url.cdn(props.data.bgImgUrl)}) no-repeat top center / 100% auto`,
fontSize: `${props.data.titleSize}px`,
fontWeight: `${props.data.titleWeight}px`,
// bgType
return {
background: bgType === 'img' ? `url(${bgImg}) no-repeat top center / 100% 100%` : bgColor
};
});
//
const titleStyles = {