Add support for global declaration of Vue components
See original GitHub issueDoes vue native support global component feature?
i’ve tried this code but seems it doesn’t work:
import MyComponent from './MyComponent';
Vue.component('my-component', MyComponent);
Issue Analytics
- State:
- Created 4 years ago
- Comments:5
Top Results From Across the Web
Add global variable in Vue.js 3 - Stack Overflow
Is there a way to declare global variables from outside the main app creation file? In Vue 2 I used to import Vue...
Read more >Component Registration - Vue.js
Global registration prevents build systems from removing unused components (a.k.a "tree-shaking"). If you globally register a component but end up not using it ......
Read more >What To Do When You Need a Global Variable in Vue 3 - Telerik
A global state provided by these libraries allows you to inject it into any component in your application, making it an ideal place...
Read more >how to make a component global in vue Code Example
in main =.js Vue.prototype.$appName = 'My App' ////in components console.log(this.$appName)
Read more >Accessing global variables in vue components - Laracasts
Hello! I have declared some javascript variables in blade view files like this: And i need to use them in vue components:
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi @AbidKhairyAK and @icarter09 ,
since I ran into the same issue today, I came up with quite a simple workaround just using the Vue plugin capability. To register components globally, you just need to write your own little plugin like this:
In your app entry file you can just use that plugin like this:
I hope this helps, although the answer might have come a little late.
@AbidKhairyAK I don’t believe this is supported.
Vue.component
is not being picked up on as valid syntax when I tested it. I would put this down as a feature request or enhancement.@sanketsahusoft can you add the ‘Enhancement’ label or ‘Feature Request’ label to this ticket? Thanks.