Closed artyprog closed 7 years ago
Hey,
Please checkout the latest release and check this updated doc:
https://github.com/InCuca/vue-standalone-component#building
Let me know if you need something else opening this issue again. Thanks!
Thank you very much but I still can't make it work
<html>
<head>
<script src="https://unpkg.com/vue" charset="utf-8"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/document-register-element/1.7.0/document-register-element.js"></script>
<script src="my-cmp.min.js" charset="utf-8"></script>
</head>
<body>
<script type="text/javascript">
Vue.component('my-cmp', window.MyCmp);
</script>
<my-cmp text="Hexxxxllo World!"></my-cmp>
</body>
</html>
Nothing display on the page, what am I doing wrong ?
You will need to wrap an element to use Vue components inside of a vue instance, in your example:
<html>
<head>
<script src="https://unpkg.com/vue" charset="utf-8"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/document-register-element/1.7.0/document-register-element.js"></script>
<script src="my-cmp.min.js" charset="utf-8"></script>
</head>
<body>
<div id="app">
<my-cmp text="Hexxxxllo World!"></my-cmp>
</div>
<script type="text/javascript">
Vue.component('my-cmp', window.MyCmp);
new Vue({el: '#app'});
</script>
</body>
</html>
Great :-) thanks again
@klarkc - seem to be having issues with the cjs build and running it in a standalone html doc.
used this snippet here
<html>
<head>
<script src="https://unpkg.com/vue" charset="utf-8"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/document-register-element/1.7.0/document-register-element.js"></script>
<script src="my-cmp.min.js" charset="utf-8"></script>
</head>
<body>
<div id="app">
<my-cmp text="Hexxxxllo World!"></my-cmp>
</div>
<script type="text/javascript">
Vue.component('my-cmp', window.MyCmp);
new Vue({el: '#app'});
</script>
</body>
</html>
but im getting the error that module is not defined in my minified file. i.e. the first line of the web packed file
module.exports = ...
Any idea if I am missing something?
Just sorted it out.
had to use
Vue.component('my-cmp', window.MyCmp.default);
Hello,
I can't see how you can integrate the standalone component in the browser. Could you give an example ?
I used to use vue build --prod --lib which does not work anymore
Regards