useSplitAttrs 组合
Quasar v2.15+
组件中 Vue 的 attrs
可以同时包含监听器和真实的 HTML 属性。useSplitAttrs()
可组合项将此 Vue 属性对象分解为两类,并保持更新。
¥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)
¥Syntax
import { useSplitAttrs } from 'quasar'
setup () {
const {
attributes,
listeners
} = useSplitAttrs()
// ...
}
content_paste
import { Ref } from 'vue'
function useSplitAttrs(): {
attributes: Ref<Record<string, string | null | undefined>>;
listeners: Ref<Record<string, (...args: any[]) => any>>;
};
content_paste
示例(Example)
¥Example
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
// ...
}
content_paste