Answer the question
In order to leave comments, you need to log in
Packaging Angular or Vue into one file for use on a third party site?
There is a task - Create a plug-in for placement on third-party sites. To implement it, I would like to use Angular or Vue. But there is no knowledge on how to pack it all into 1 file so that by connecting 1 js file, you can draw all the necessary menus in the required place on the site.
Those. plug-in like Yandex maps.
Answer the question
In order to leave comments, you need to log in
For example, you can do this:
in your script, create a global object and make an initialization function that will create a vue instance and bind it to the corresponding element on the site.
In general terms, something like this:
on the site:
<script src="path_to_script"></script>
<script type="text/javascript">
var vm;
vm = vuecomp.init("vuecomponent", {
// some options
});
</script>
<div id="vuecomponent"></div>
import Vue from 'vue'
// ...
const vuecomp = {
init(elementId, options) {
return new Vue({
el: `#${elementId}`,
// ...
})
}
}
export default vuecomp
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question