I am starting to use the vue composition API which is great for data, api calls etc. It works perfectly and cleans up my code.
I am not starting to think can I use it to create components. Probably not massive components but modals or something like that. I have not seen any examples where the composition function (I extract them to external .js files) provides a render function and creates the html, slots etc on the component.
Is this possible and good practice?
This is what I have so far but it will not render
import { reactive, ref, computed } from '@vue/composition-api';
import Vue from 'vue';
export default function test () {
const myButton = Vue.component('button-counter', {
data: function () {
return {
count: 0
}
},
template: '<button>You clicked me {{ count }} times.</button>'
})
return {
myButton
};
}
In the component where I am trying to use it
setup() {
const { myButton } = useTest();
return { myButton };
},
function VueComponent (options) { this._init(options); }
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…