Vue 的 attrs
在元件中可以同時包含監聽器和真實的 HTML 屬性。useSplitAttrs()
composable 將這個 Vue 屬性物件分解成兩個類別,並保持它們更新。
語法
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
範例
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