vue-demi
vue-demi copied to clipboard
setup() fires in defineComponent for Vue3 but not for Vue2, render() fires for both
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];
}
});