-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ui): new composable - useSplitAttrs()
- Loading branch information
1 parent
18cfba5
commit 0299efa
Showing
9 changed files
with
116 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
--- | ||
title: useSplitAttrs composable | ||
desc: What is useSplitAttrs() composable and how you can use it | ||
keys: useSplitAttrs | ||
badge: Quasar v2.15+ | ||
--- | ||
|
||
Vue's `attrs` in a component can contain both listeners and real HTML attributes. The `useSplitAttrs()` composable breaks down this Vue attr object into the two categories and keeps them updated. | ||
|
||
## Syntax | ||
|
||
```js | ||
import { useSplitAttrs } from 'quasar' | ||
|
||
setup () { | ||
const { | ||
attributes, | ||
listeners | ||
} = useSplitAttrs() | ||
|
||
// ... | ||
} | ||
``` | ||
|
||
```js | ||
function useSplitAttrs(): { | ||
attributes: Ref<Record<string, any>>; | ||
listeners: Ref<Record<string, any>>; | ||
}; | ||
``` | ||
|
||
## Example | ||
|
||
```js | ||
import { useSplitAttrs } from 'quasar' | ||
|
||
setup () { | ||
const { | ||
attributes, // is a Vue ref() | ||
listeners // is a Vue ref() | ||
} = useSplitAttrs() | ||
|
||
console.log(attributes.value) | ||
// prints out a key-value object | ||
|
||
console.log(listeners.value) | ||
// prints out a key-value object | ||
|
||
// ... | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,19 @@ | ||
import useRenderCache from './composables/use-render-cache.js' | ||
import useDialogPluginComponent from './composables/use-dialog-plugin-component.js' | ||
import useFormChild from './composables/use-form-child.js' | ||
import useMeta from './composables/use-meta.js' | ||
import useQuasar from './composables/use-quasar.js' | ||
import useRenderCache from './composables/use-render-cache.js' | ||
import useSplitAttrs from './composables/use-split-attrs.js' | ||
import useTick from './composables/use-tick.js' | ||
import useTimeout from './composables/use-timeout.js' | ||
|
||
export { | ||
useRenderCache, | ||
useDialogPluginComponent, | ||
useFormChild, | ||
useMeta, | ||
useQuasar, | ||
useRenderCache, | ||
useSplitAttrs, | ||
useTick, | ||
useTimeout | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 4 additions & 2 deletions
6
...rc/composables/private/use-split-attrs.js → ui/src/composables/use-split-attrs.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters