Closed negezor closed 3 years ago
@negezor plz update to v4.9.0
and retry
https://kabbouchi.github.io/vue-tippy/4.0/features/composition-api.html#example-5
It works, thanks! Taking this opportunity, how can useTippy()
be initialized asynchronously? Since by default it always requires an element to trigger.
I didn't fully understand the question, can u provide a basic example (a broken example is fine)?
for vue-tippy@next
you can disable automount and trigger it manually:
import { useTippy } from 'vue-tippy';
const element = ref();
const { mount, unmount } = useTippy(element, { arrow : true } , { mount : false })
const mountTippy = (el : Element) {
umount() // safely unmount previous element/instance if exist
element.value = el
mount()
}
mountTippy(...) // call it any time you want
is that what you're looking for?
I modify the first example for clarity. This will throw an error before the data is loaded.
<template>
<div>
<div v-if="!loading">
<BaseButton
label="Open dropdown"
ref="triggerElement"
/>
<div ref="contentElement">
Content
</div>
</div>
</div>
</template>
<script lang="ts">
import { defineComponent, ref } from '@vue/composition-api';
import { useTippy } from 'vue-tippy/composition';
import { BaseButton } from '@/components';
export default defineComponent({
components: {
BaseButton
},
setup() {
const loading = ref(false);
setTimeout(() => {
// Load data from server...
loading.value = false;
}, 1e3);
const triggerElement = ref(null);
const contentElement = ref(null);
const { tippy } = useTippy(triggerElement, {
content: contentElement,
placement: 'bottom',
animation: 'shift-away',
role: 'dropdown',
arrow: false,
trigger: 'click',
appendTo: 'parent',
interactive: true
});
return {
loading,
tippy,
triggerElement,
contentElement
};
}
});
</script>
The vue-tippy@next
looks like what I need. Unfortunately I cannot use vue-tippy@next
as it is for Vue 3. I am using Nuxt.js with Composition API.
I've released a new version v4.10.0
now you can mount/unmount manually
https://kabbouchi.github.io/vue-tippy/4.0/features/composition-api.html?v4.10#example-6
That's very helpful, thank you.
I get an error when I try to use a hook with a component
And
TheNavigation.vue
BaseButton.vue