Comments (3)
from ant-design-vue.
封装
import { computed } from 'vue'
import { theme } from 'ant-design-vue'
import { css } from '@emotion/css'
import type { UnwrapRef } from 'vue'
import type { CSSInterpolation } from '@emotion/css'
export type ThemeToken = UnwrapRef<ReturnType<typeof theme.useToken>>['token']
export type GenCSSInterpolation = (token: ThemeToken) => CSSInterpolation | CSSInterpolation[]
export function useEmotionCss(genCss: GenCSSInterpolation) {
const { token } = theme.useToken()
return computed(() => css(genCss(token.value)))
}
应用
<script setup lang="ts">
import { useEmotionCss } from '@/hooks'
import { useSystemStore } from '@/store'
const system = useSystemStore()
defineOptions({
name: 'Editer'
})
const css = useEmotionCss(token => ({
color: token.colorText,
}))
const handleSwitchMode = () => {
system.changeThemeMode(system.mode == 'dark' ? 'light' : 'dark')
}
</script>
<template>
<div :class="css">
<p>123131232</p>
<button @click="handleSwitchMode">切换</button>
</div>
</template>
from ant-design-vue.
感谢各位
from ant-design-vue.
Related Issues (20)
- Pagination 更多分页省略号出现向下偏移 HOT 1
- 基于input二次封装,怎么在form中使用 HOT 7
- antd vue 4.x官网崩了,不能看了 HOT 4
- 按照配置自动引入后 打包体积还是一点多兆
- a-input添加allow-clear属性,点击删除图标报target.cloneNode is not a function HOT 2
- Form.Item tooltip slot not working HOT 1
- 针对谷歌浏览器升级的128内核对zoom的处理body 进行缩放偏移问题 HOT 2
- body使用zoom做缩放自适应 组件下拉(select)zoom不等于1时 定位错误 发生偏移 HOT 1
- 一些组件(例如select组件onChange/onSearch)传递props绑定事件时使用时报警告[warning] Expected Function, got Array, 导致后续触发事件时报错, 因为组件内部props事件传递给子组件时将function处理成Array了 HOT 2
- a-select 失焦bug,无法失焦,官网demo即可复现
- 官方不打算维护了?
- a-directory-tree 点击标题行时 expand 会触发两次 HOT 1
- AutoComplete maxlength属性不生效
- 图片预览组件是否支持视频或者加一个插槽
- 图片预览组件是否支持视频或者加一个插槽
- date-picker-demo-disabled, today is disabled but 'now' can be click in default date-picker HOT 1
- a-slider这类组件增加事件冒泡和默认事件的选项以便应用于更多场景
- Invalid prop: type check failed for prop "onRemove". Expected Function, got Array
- tree-select使用allow-clear和field-names 数据展示异常
- 预览图片的时候,顺序会颠倒 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ant-design-vue.