1***@qq.com
1***@qq.com
  • 发布:2025-04-07 17:30
  • 更新:2025-04-09 20:02
  • 阅读:139

【报Bug】style标签不能正确渲染

分类:uni-app

产品分类: uniapp/小程序/抖音

PC开发环境操作系统: Mac

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

HBuilderX类型: 正式

HBuilderX版本号: 4.45

第三方开发者工具版本号: 4.3.7

基础库版本号: 3.60.0.7

项目创建方式: HBuilderX

示例代码:

<view class="barrage-container" :style="getContainerStyle" v-show="barrageConfig.isShow">  
      <view v-for="barrage in barrageList" :key="barrage.id" class="barrage-item" :style="barrage.style">  
        {{ barrage.text }}  
      </view>  
    </view>  

 computed: {  
    // 计算弹幕容器样式  
    getContainerStyle() {  
      const style = {  
        height: this.barrageConfig.position === "full" ? "300px" : "150px",  
      };  

      if (this.barrageConfig.position === "bottom") {  
        style.top = "150px";  
      }  

      return style;  
    },  
}
```vue  

操作步骤:

~~

预期结果:

正确渲染style

实际结果:

标签上没有style

bug描述:

动态style不能正确渲染,

2025-04-07 17:30 负责人:无 分享
已邀请:
DCloud_UNI_OttoJi

DCloud_UNI_OttoJi - 日常回复 uni-app/x 问题,如果艾特我没看到,请主动私信

提供完整单页面源码。我使用下面打代码,在 vue3 抖音小程序上表现这个正常

<template>  
  <view>  
    <view @click="toggle">{{height300}}</view>  
    <view class="barrage-container" :style="getContainerStyle" v-show="height300">  
      123  
    </view>  
  </view>  
</template>  

<script>  
  export default {  
    data() {  
      return {  
        height300: false,  
      }  
    },  
    methods: {  
      toggle() {  
        this.height300 = !this.height300  
      }  
    },  
    computed: {  
      // 计算弹幕容器样式    
      getContainerStyle() {  
        const style = {  
          border:'1px solid red',  
          height: this.height300 === true ? "300px" : "150px",  
        };  

        return style;  
      },  
    }  
  }  
</script>  
  • DCloud_UNI_OttoJi

    你也观察模拟器上的 html 倒是有没有 style 值,把结果说一下

    2025-04-09 20:03

要回复问题请先登录注册