Skip to content

Syntax sugar for extending components #149

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

Closed
yyx990803 opened this issue Feb 28, 2014 · 5 comments
Closed

Syntax sugar for extending components #149

yyx990803 opened this issue Feb 28, 2014 · 5 comments

Comments

@yyx990803
Copy link
Member

Currently, to extend a registered component you'd have to do this:

Vue.component('a', {})
Vue.component('b', Vue.component('a').extend({
   // ...
})

or

var A = Vue.extend({})
var B = A.extend({})
Vue.component('a', A)
Vue.component('b', B)

I'm thinking of a new syntax to make this easier, maybe something like this:

Vue
  .component('form', {})
  .component('login-form', 'form', {}) // login-form extends form

Thoughts?

@bpierre
Copy link

bpierre commented Feb 28, 2014

Vue.component could also return the created component, but I guess that it could be a source of confusion.

Another approach, more explicit:

Vue.component('form', {})
Vue.component('login-form', { extends: 'form' })

// …but this is where it becomes a horrible idea :(
var Form = Vue.extend({})
var LoginForm = Vue.extend({ extends: 'form' })

@yyx990803
Copy link
Member Author

I know extends option would be confusing too, haha that's why I didn't mention it

@th0r
Copy link

th0r commented Feb 28, 2014

Maybe return new created objects from all static Vue methods? Chaining is not very necessary in this case, imho.

@dyu
Copy link

dyu commented Feb 28, 2014

Or C++ style extend ...
Vue
.component('form', {})
.component('login-form:form', {}) // login-form extends form

@yyx990803
Copy link
Member Author

closing due to lack of consensus and the benefits is not that substantial.

Hanks10100 pushed a commit to Hanks10100/vue that referenced this issue May 6, 2018
Hanks10100 pushed a commit to Hanks10100/vue that referenced this issue May 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants