Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for global declaration of Vue components #154

Open
AbidKhairyAK opened this issue May 31, 2019 · 5 comments
Open

Add support for global declaration of Vue components #154

AbidKhairyAK opened this issue May 31, 2019 · 5 comments
Labels
enhancement New feature or request

Comments

@AbidKhairyAK
Copy link

Does 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);
@icarter09
Copy link

@AbidKhairyAK were you able to figure this issue out or solve it?

@AbidKhairyAK
Copy link
Author

@icarter09 NO,
I have not been able to solve this problem. until now, I still import custom components on every file that needs it

@icarter09
Copy link

@AbidKhairyAK thanks for heads up. I'll try to recreate the issue and dig into it.

@icarter09
Copy link

@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.

@RishabhKarnad RishabhKarnad added the enhancement New feature or request label Sep 16, 2019
@RishabhKarnad RishabhKarnad changed the title Does it support global component feature? Add support for global declaration of Vue components Sep 16, 2019
@crolly
Copy link

crolly commented May 4, 2020

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:

import componentA from './componentA'

export default {
  // The install method is all that needs to exist on the plugin object.
  // It takes the global Vue object as well as user-defined options.
  install(Vue) {
    Vue.component('component-name', componentA)
  }
}

In your app entry file you can just use that plugin like this:

import Vue from 'vue-native-core'

import components from './src/components'
Vue.use(components)

I hope this helps, although the answer might have come a little late.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants