Last active
April 18, 2021 12:10
-
-
Save yaman3bd/0567a41d03eea5044a293d2ae9e95eaa to your computer and use it in GitHub Desktop.
Auto register Vue3 components
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//in your app.js add this: | |
window.Vue = require('vue'); | |
const app = Vue.createApp({}); | |
const files = require.context('./', true, /\.vue$/i); | |
files.keys().map(function (key) { | |
app.component(key.split('/').pop().split('.')[0], files(key).default); | |
}); | |
app.mount('#app'); | |
//in your HTML should be like: | |
<body class="come-class"> | |
<div id="app" class="come-class"> | |
<my-component></my-component> | |
</div> | |
</body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment