Dora24678
Dora24678
  • 发布:2025-12-01 17:49
  • 更新:2025-12-01 17:49
  • 阅读:20

【报Bug】style 字符串拼接出现出现问题

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Mac

PC开发环境操作系统版本号: macoS 26.1

HBuilderX类型: 正式

HBuilderX版本号: 4.85

手机系统: HarmonyOS NEXT

手机系统版本号: HarmonyOS 5.1.1

手机厂商: 华为

手机机型: HUAWEI Pocket 2

页面类型: vue

vue版本: vue3

打包方式: 云端

项目创建方式: HBuilderX

操作步骤:

如下源码会导致 v-show 失效:

<template>  
    <view>  
        <view class="dialog_nav" :style="'top:' + navH + 'rpx;'" v-show="currentPage">  
            <text>内容</text>  
        </view>  
    </view>  
</template>  

<script>  
    export default {  
        data() {  
            return {  
                navH: 100,  
                currentPage: false  
            };  
        }  
    };  
</script>

如下代码符合预期:

<template>  
    <view>  
        <view class="dialog_nav" :style="{ top: `${navH}rpx` }" v-show="currentPage">  
            <text>内容</text>  
        </view>  
    </view>  
</template>  

<script>  
    export default {  
        data() {  
            return {  
                navH: 100,  
                currentPage: false  
            };  
        }  
    };  
</script>

预期结果:

style 支持字符串拼接

实际结果:

bug描述:

如下源码会导致 v-show 失效:

<template>  
    <view>  
        <view class="dialog_nav" :style="'top:' + navH + 'rpx;'" v-show="currentPage">  
            <text>内容</text>  
        </view>  
    </view>  
</template>  

<script>  
    export default {  
        data() {  
            return {  
                navH: 100,  
                currentPage: false  
            };  
        }  
    };  
</script>

如下代码符合预期:

<template>  
    <view>  
        <view class="dialog_nav" :style="{ top: `${navH}rpx` }" v-show="currentPage">  
            <text>内容</text>  
        </view>  
    </view>  
</template>  

<script>  
    export default {  
        data() {  
            return {  
                navH: 100,  
                currentPage: false  
            };  
        }  
    };  
</script>
2025-12-01 17:49 负责人:无 分享
已邀请:

要回复问题请先登录注册