
- 发布:2024-03-30 13:14
- 更新:2024-03-30 13:43
- 阅读:309
产品分类: uniapp/App
PC开发环境操作系统: Mac
PC开发环境操作系统版本号: 12.7.3
HBuilderX类型: 正式
HBuilderX版本号: 4.07
手机系统: 全部
页面类型: nvue
vue版本: vue3
打包方式: 云端
项目创建方式: HBuilderX
测试过的手机:
示例代码:
<template>
<view class="content">
<image class="logo" src="/static/logo.png"></image>
<view class="box" :class="[a ? 'active' : '']" @click="boxClick"></view>
</view>
</template>
<script setup>
import {ref} from 'vue'
const a = ref(false)
const tabClick = () => a.value = !a.value
</script>
<style>
.content {
width: 750rpx;
height: 750rpx;
}
.box {
height: 400rpx;
width: 400rpx;
background-color: red;
}
.active {
background-color: yellow;
}
</style>
<template>
<view class="content">
<image class="logo" src="/static/logo.png"></image>
<view class="box" :class="[a ? 'active' : '']" @click="boxClick"></view>
</view>
</template>
<script setup>
import {ref} from 'vue'
const a = ref(false)
const tabClick = () => a.value = !a.value
</script>
<style>
.content {
width: 750rpx;
height: 750rpx;
}
.box {
height: 400rpx;
width: 400rpx;
background-color: red;
}
.active {
background-color: yellow;
}
</style>
操作步骤:
无
无
预期结果:
动态类名生效
动态类名生效
实际结果:
动态类名不生效
动态类名不生效
bug描述:
动态类名不生效 随便一个nvue + vue3的项目就能复现
2 个回复
YZL_zyzl (作者)
这是vue2,是可以的
尘封11
const boxClick = () => a.value = !a.value
YZL_zyzl (作者)
这个忘了删了,其实就是不行
2024-03-30 13:59
YZL_zyzl (作者)
好同志,你试试行不行
2024-03-30 14:06
困难总比办法多
回复 YZL_zyzl: 应该是bug,数组写法改成对象写法吧
2024-03-30 17:46