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

Docs Suggestion - Update method definitions to use ECMAScript 2015 shorter syntax #9683

Closed
rdhelms opened this Issue Mar 12, 2019 · 1 comment

Comments

Projects
None yet
2 participants
@rdhelms
Copy link

rdhelms commented Mar 12, 2019

What problem does this feature solve?

Currently in the Vue docs, methods are defined using the methodName: function () {} syntax, such as for the data method below:

Current Example: https://vuejs.org/v2/guide/components.html

// Define a new component called button-counter
Vue.component('button-counter', {
  data: function () {
    return {
      count: 0
    }
  },
  template: '<button v-on:click="count  ">You clicked me {{ count }} times.</button>'
})

But it is very common in tutorials, articles, and other Vue apps to use the shorter method definition syntax, described by MDN here:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Method_definitions

It would improve readability and minimize context-switching if the Vue docs could also use this newer syntax. Outside of the Vue documentation, it seems more and more rare to find methods with the older syntax.

What does the proposed API look like?

Proposed Example:

// Define a new component called button-counter
Vue.component('button-counter', {
  data () {
    return {
      count: 0
    }
  },
  template: '<button v-on:click="count  ">You clicked me {{ count }} times.</button>'
})
@posva

This comment has been minimized.

Copy link
Member

posva commented Mar 12, 2019

This is intentional to keep docs approachable to everyone but we might include multiple versions in future versions of the docs. BTW, the docs are at vuejs/vuejs.org repo 🙂

@posva posva closed this Mar 12, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.