Skip to content

data should be function #797

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
trollepierre opened this issue Jul 3, 2018 · 3 comments · Fixed by #835
Closed

data should be function #797

trollepierre opened this issue Jul 3, 2018 · 3 comments · Fixed by #835
Labels

Comments

@trollepierre
Copy link
Contributor

trollepierre commented Jul 3, 2018

Version

1.0.0-beta.20

Reproduction link

Steps to reproduce

Open this:

 data: { test: '' } 

should be written as

data: () => ({ test: '' })

What is expected?

data: () => ({ test: '' })

What is actually happening?

data: { test: '' }


https://vuejs.org/v2/guide/components.html#data-Must-Be-a-Function

@eddyerburgh
Copy link
Member

Would you like to open a PR to make the change?

@LinusBorg LinusBorg added the bug label Jul 4, 2018
@Mardoxx
Copy link

Mardoxx commented Jul 4, 2018

Does it have to be a function?

https://vuejs.org/v2/examples/

new Vue({
  el: '#editor',
  data: {
    input: '# hello'
  },
  computed: {
    compiledMarkdown: function () {
      return marked(this.input, { sanitize: true })
    }
  },
  methods: {
    update: _.debounce(function (e) {
      this.input = e.target.value
    }, 300)
  }
})

E: Ahh I see this is a simple example which isn't a reusable component... makes sense. 😄

@eddyerburgh
Copy link
Member

eddyerburgh commented Jul 4, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
4 participants