凌风浮云S
凌风浮云S
  • 发布:2025-11-13 09:28
  • 更新:2025-11-13 09:28
  • 阅读:21

【报Bug】uniappx中backgroundImage 不能使用图片 也不能使用颜色变量

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: Windows 10 企业版 LTSC 21H2

HBuilderX类型: 正式

HBuilderX版本号: 4.85

手机系统: Android

手机系统版本号: Android 16

手机厂商: 小米

手机机型: 红米K70至尊

页面类型: vue

vue版本: vue3

打包方式: 云端

项目创建方式: HBuilderX

示例代码:

uni.scss文件

.theme-light {  
    --primaryColorbg3: #ffd6a3;  
    --baseColor: #FAF7F5;  
}

index.uvue文件

<template>  
    <view class="login-container" :class="themeState.theme">  
        <!-- <button @click="change()">1111</button> -->  
    </view>  
</template>  

<script setup lang="uts">  
    import { themeState, setTheme } from '@/store/theme.uts'  

    const color = '#ffd6a3'  

    function change() {  
        setTheme(themeState.theme == 'theme-dark' ? 'theme-light' : 'theme-dark')  
    }  
</script>  

<style lang="scss">  
    .login-container {  
        width: 750rpx;  
        height: 1624rpx;  
        background-image: linear-gradient(180deg, var(--primaryColorbg3) -10%, var(--baseColor) 30%);  
    }  
</style>

操作步骤:
<template>  
    <view class="login-container" :class="themeState.theme">  
        <!-- <button @click="change()">1111</button> -->  
    </view>  
</template>  

<script setup lang="uts">  
    import { themeState, setTheme } from '@/store/theme.uts'  

    const color = '#ffd6a3'  

    function change() {  
        setTheme(themeState.theme == 'theme-dark' ? 'theme-light' : 'theme-dark')  
    }  
</script>  

<style lang="scss">  
    .login-container {  
        width: 750rpx;  
        height: 1624rpx;  
        background-image: linear-gradient(180deg, var(--primaryColorbg3) -10%, var(--baseColor) 30%);  
    }  
</style>
.theme-light {  
    --primaryColorbg3: #ffd6a3;  
    --baseColor: #FAF7F5;  
}

预期结果:

预期应该是颜色变量和图片都可以使用

实际结果:

实际结果是颜色变量和图片都不生效

bug描述:

开发环境中 做换肤功能时 发现渐变背景不能使用颜色变量
background-image: linear-gradient(180deg, var(--primaryColorbg3) -10%, var(--baseColor) 30%); #真机预览不生效
background-image: '/static/logo.png'; #文档中说可以使用图片 但是也不生效

2025-11-13 09:28 负责人:无 分享
已邀请:

要回复问题请先登录注册