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

[官方文档] 文档的 暗黑模式 一文中 手动切换暗色模式部分 提供的代码不可用 #23

Open
zhiguai opened this issue Sep 24, 2024 · 0 comments

Comments

@zhiguai
Copy link

zhiguai commented Sep 24, 2024

iui-design 版本

1.0.0-alpha.5

重现步骤

https://iyunci.cn/design/uni/dark.html

<template>
  <iui-switch v-model="darkmode" @change="onChange" />
</template>

<script setup>
  import { ref, computed } from "vue";
  const darkmode = ref(false);

  const onChange = () => {
    if (darkmode.value) {
      // 切换到暗色模式
      document.documentElement.setAttribute("class", "dark");
    } else {
      // 切换到浅色模式
      document.documentElement.removeAttribute("class");
    }
  };
</script>

期望结果

No response

实际结果

无效

框架版本

No response

浏览器版本

No response

系统版本

No response

运行平台

No response

补充说明

经测试目前正解

<template>
  <iui-switch v-model="darkmode" @change="onChange" />
</template>

<script setup>
  import { ref, computed } from "vue";
  const darkmode = ref(false);

  const onChange = () => {
    if (darkmode.value) {
      // 切换到暗色模式
      document.documentElement.setAttribute("class", "dark");
    } else {
      // 切换到浅色模式 正解在此
      document.documentElement.setAttribute("class", "light");
    }
  };
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant