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

前端:clsx 构造最佳的css类名 #109

Open
lauer3912 opened this issue Jun 3, 2022 · 0 comments
Open

前端:clsx 构造最佳的css类名 #109

lauer3912 opened this issue Jun 3, 2022 · 0 comments
Labels
库推荐 推荐的库 组件 产品重要组成部分 资源库 问题解答

Comments

@lauer3912
Copy link
Owner

https://www.npmjs.com/package/clsx

import clsx from 'clsx';
 
// Strings (variadic)
clsx('foo', true && 'bar', 'baz');
//=> 'foo bar baz'
 
// Objects
clsx({ foo:true, bar:false, baz:isTrue() });
//=> 'foo baz'
 
// Objects (variadic)
clsx({ foo:true }, { bar:false }, null, { '--foobar':'hello' });
//=> 'foo --foobar'
 
// Arrays
clsx(['foo', 0, false, 'bar']);
//=> 'foo bar'
 
// Arrays (variadic)
clsx(['foo'], ['', 0, false, 'bar'], [['baz', [['hello'], 'there']]]);
//=> 'foo bar baz hello there'
 
// Kitchen sink (with nesting)
clsx('foo', [1 && 'bar', { baz:false, bat:null }, ['hello', ['world']]], 'cya');
//=> 'foo bar hello world cya'
@lauer3912 lauer3912 added 问题解答 资源库 组件 产品重要组成部分 库推荐 推荐的库 labels Jun 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
库推荐 推荐的库 组件 产品重要组成部分 资源库 问题解答
Projects
None yet
Development

No branches or pull requests

1 participant