vuejs / vue

This is the repo for Vue 2. For Vue 3, go to https://github.com/vuejs/core
http://v2.vuejs.org
MIT License
207.66k stars 33.67k forks source link

[Help Needed/Feature Request] Custom Key needed in Vue's Export Default #8156

Closed IamManchanda closed 6 years ago

IamManchanda commented 6 years ago

Important Note

I don't want this to happen in Vue, I just want to know how can I implement this in my projects. If this can't be done right now ... Then this is a feature request of CustomKey If this can already happen ... Then Please tell me how I can and happy to close!


What problem does this feature solve?

Keeping things short

I want to duplicate this below stuff

export default {
  components: {
    ComponentAdam,
    ComponentMadam,
  },
};

and make something like this ...

export default {
  components: {
    ComponentAdam,
    ComponentMadam,
  },
  objects: {
    ObjectSierra,
    ObjectHotel,
    ObjectIndia,
    ObjectEcho,
    ObjectLima,
    ObjectDelta,
  },
};

What does the proposed API look like?

Not exactly sure!

IamManchanda commented 6 years ago

cc @yyx990803

fnlctrl commented 6 years ago

What you need is probably mixins. If that is not the case, please provide more information about why you need this, what are the possible use cases etc.

IamManchanda commented 6 years ago

No @fnlctrl

I don't need mixins ... What I want is a custom key where I can load components instead but with different key name

please provide more information about why you need this, what are the possible use cases etc.

I want to follow this pattern => http://oocss.org/ It might be for CSS but i want this for JavaScript/Vue Components also

Where I can distinguish what are my components and what are my objects

From an article from another Harry

Object: Signify that something is an Object, and that it may be used in any number of unrelated contexts to the one you can currently see it in. Making modifications to these types of components could potentially have knock-on effects in a lot of other unrelated places. Tread carefully.

Example: objects/accordion.vue

Component: Signify that something is a Component. This is a concrete, implementation-specific piece of UI. All of the changes you make to this should be detectable in the context you’re currently looking at. Modifying these should be safe and have no side effects.

Example: components/navigation/sidenav.vue

IamManchanda commented 6 years ago

@fnlctrl I am looking for reply!

yyx990803 commented 6 years ago

Honestly I find it hard to understand what you are trying to achieve. Custom fields e.g. foo can be accessed as this.$options.foo. Other than that, please note issues are only for well defined feature requests - it should not be used for seeking help. If you don't know what you want, discuss it on the forum first.