vue-demi icon indicating copy to clipboard operation
vue-demi copied to clipboard

setup() fires in defineComponent for Vue3 but not for Vue2, render() fires for both

Open rlightner opened this issue 3 years ago • 0 comments

Running a Vite Vue app. Is there something I'm missing to get the setup method to be called when running under Vue2?

import { defineComponent, onBeforeMount, onMounted } from 'vue-demi'

export default defineComponent({
    name: 'ComponentName',
    created() {
        console.log('created');
    },
    beforeMount() {
        console.log('V2 beforeMount!');
    },
    mounted() {
        console.log('V2 mounted!');
    },
    setup() {
        console.log('setup');

        onBeforeMount(() => {
            console.log('V3 beforeMount!');
        })

        onMounted(() => {
            console.log('V3 mounted!');
        })
    },
    render() {
        const slot =
            typeof this.$slots.default === 'function'
                ? this.$slots.default()
                : this.$slots.default;
        return slot && slot[0];
    }
});

rlightner avatar May 06 '22 02:05 rlightner