Reputation: 655
I created an api. And for him, I created a one-page interface using vuecli. My plans are to embed it in the projects I need. The question is what needs to be done to export the written application and reuse it where necessary?
The structure of the project is shown in the screenshot.
src/main.js
- connect and configure axiossrc/App.vue
- I describe the main component of the application
(maybe I need to put it in a separate component in the components
folder)src/components/OneDay.vue
is the second component that is mainly
called src/App.vue
several times.src/mixins/dateHandler.js
- several functions common to the two
components, which are connected as mixins.I have not modified any other files. How can I prepare this correctly so that I can connect these components to my other applications using composer? I connect, configure some variables (api address, for example) and display it in the right place on the page - this is how I see it.
Upvotes: 3
Views: 737
Reputation: 287
You can try to create a web component using VUE CLI 3 to use it later in a different code base. Just make sure your main.js
file looks like this
import Vue from 'vue';
import wrap from '@vue/web-component-wrapper';
import VueWebComponent from './components/VueWebComponent';
const CustomElement = wrap(Vue, VueWebComponent);
window.customElements.define('my-custom-element', CustomElement);
and build it using vue-cli-service build
with --target wc
You can read more precise instructions there: https://github.com/vuejs/vue-web-component-wrapper https://vuejsdevelopers.com/2018/05/21/vue-js-web-component/
Upvotes: 4