Comments (6)
theme
现在的设计就是响应式的。但是他现在的实现不是一个单例模式。如果想跨组件使用。其实是可以自己在包一层。放到一个更大的context去做这件事。
from fect.
比如我们可以创建一个hook
const globalKey = Symbol('globalState')
export const createGlobalState = () => {
const { theme, themeChange } = useTheme()
const state = { theme, themeChange }
return {
install(app) {
app.provide(globalKey, state)
},
}
}
export const useGlobalState = () => inject(globalKey)
然后挂载到createApp
的use
方法上
from fect.
如果考虑实现单例模式。可以说下具体的原因吗。
from fect.
html的class是统一的,所以theme应该是全局唯一的,我已经在其他组件通过themeChange修改了html的class,但是获取到theme却是另一个,这并不合理
from fect.
@QiYuOr2 这么一看确实得这样修改. :)
from fect.
我会创建pull request. 功能会随着下个版本rc.2
进行发布。
from fect.
Related Issues (20)
- [Feature]: Add Virtual list component. HOT 2
- Hope to add button width HOT 3
- Modal didn't achieve the expected effect HOT 3
- Stacking issue when using multiple select in modal HOT 3
- Error when importing form components on demand using Vite HOT 3
- [Feature]: V1.4.0 Planning HOT 3
- [Bug] radio组件的value初始化值为字符串时报错 HOT 1
- 输入框的密码样式出现两个隐藏密码按钮 HOT 8
- 模态框中使用多选框,无法正常使用 HOT 2
- [Bug] 卡片组件部分样式缺失 HOT 2
- Add deployment snapshot for pr. HOT 6
- Future changes -- With Scale System. HOT 3
- [Bug] fe-tabs无法通过直接改变active的value来切换tab HOT 2
- Can we change the `dark mode` color scheme of the website? HOT 2
- [Refactor]: cli part HOT 1
- [Refacotr]: refacotr docs
- New Version -- About V1.6.0
- [Feature]: Is it possible to provide a resolver for unplugin-auto-import HOT 7
- Refactor component with scale system 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 fect.