Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.6.14 无法动态删除 style #14463

Closed
bluescurry opened this issue Aug 31, 2023 · 1 comment · Fixed by #14465, #14688 or #14690
Closed

3.6.14 无法动态删除 style #14463

bluescurry opened this issue Aug 31, 2023 · 1 comment · Fixed by #14465, #14688 or #14690
Labels
F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x

Comments

@bluescurry
Copy link
Contributor

相关平台

微信小程序

小程序基础库: 3.0.1
使用框架: React

复现步骤

import React, { CSSProperties, useState } from 'react';
import { Button, View } from '@tarojs/components';

const Demo3 = () => {
  const [style, setStyle] = useState<CSSProperties>({
    "color": "red",
  });

 return (
   <View style={style}>
     <Button
       onClick={() => {
         setStyle({});
       }}
     >
       切换颜色
     </Button>
     <View className="bg">{JSON.stringify(style)}</View>
   </View>
 );
};

export default Demo3;

点击切换颜色按钮

期望结果

view 的 style 不再有 color 属性

实际结果

view 的 style 还有 color 属性,只是值变成空了

其他信息

image
style 改成 {} 后 color 属性还在,这样会导致在使用 var 变量控制样式的时候,没有把属性清除导致无法把属性值恢复成 var 变量设置的默认值。。。

环境信息

👽 Taro v3.6.14


  Taro CLI 3.6.14 environment info:
    System:
      OS: macOS 13.5.1
      Shell: 5.9 - /bin/zsh
    Binaries:
      Node: 16.15.1 - /usr/local/bin/node
      Yarn: 1.22.19 - /usr/local/bin/yarn
      npm: 8.11.0 - /usr/local/bin/npm
    npmPackages:
      @tarojs/cli: 3.6.14 => 3.6.14
      @tarojs/components: 3.6.14 => 3.6.14
      @tarojs/helper: 3.6.14 => 3.6.14
      @tarojs/plugin-framework-react: 3.6.14 => 3.6.14
      @tarojs/plugin-platform-alipay: 3.6.14 => 3.6.14
      @tarojs/plugin-platform-h5: 3.6.14 => 3.6.14
      @tarojs/plugin-platform-jd: 3.6.14 => 3.6.14
      @tarojs/plugin-platform-qq: 3.6.14 => 3.6.14
      @tarojs/plugin-platform-swan: 3.6.14 => 3.6.14
      @tarojs/plugin-platform-tt: 3.6.14 => 3.6.14
      @tarojs/plugin-platform-weapp: 3.6.14 => 3.6.14
      @tarojs/react: 3.6.14 => 3.6.14
      @tarojs/runtime: 3.6.14 => 3.6.14
      @tarojs/shared: 3.6.14 => 3.6.14
      @tarojs/taro: 3.6.14 => 3.6.14
      @tarojs/taro-loader: 3.6.14 => 3.6.14
      @tarojs/webpack5-runner: 3.6.14 => 3.6.14
      babel-preset-taro: 3.6.14 => 3.6.14
      eslint-config-taro: 3.6.14 => 3.6.14
      react: ^18.0.0 => 18.2.0
    npmGlobalPackages:
      typescript: 4.9.5
@bluescurry
Copy link
Contributor Author

@ZakaryCode 这个 PR 可以 merge 吗~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x
Projects
Archived in project
1 participant