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

[Vue warn]: The "data" option should be a function #14

Closed
lvvlan opened this issue Jul 9, 2018 · 4 comments
Closed

[Vue warn]: The "data" option should be a function #14

lvvlan opened this issue Jul 9, 2018 · 4 comments

Comments

@lvvlan
Copy link

lvvlan commented Jul 9, 2018

This is my code

<template>
    <div class="test">
        <p>{{testMobx.data}}</p>
    </div>
</template>

<script lang="ts">
import Vue from 'vue'
import Component from 'vue-class-component'
import { Observer } from 'mobx-vue'
import { observable } from 'mobx'

class TestMobx {
    @observable data = 123
}

let TestClass = new TestMobx()

@Observer
@Component
export default class App extends Vue {
    testMobx = TestClass
}
</script>

but has this warning:

[Vue warn]: The "data" option should be a function that returns a per-instance value in component definitions.

why??

@lvvlan
Copy link
Author

lvvlan commented Jul 9, 2018

I'm trying to do this

data () {
    return {
        testMobx: TestClass
    }
}

but warning still exists

@kuitos
Copy link
Member

kuitos commented Jul 9, 2018

Could you please provide a minimum reproduction with codesandbox? You can make it with this template https://codesandbox.io/s/j76vj84zw9

@lvvlan
Copy link
Author

lvvlan commented Jul 9, 2018

This is a simple demo https://codesandbox.io/s/lj3l95m09
If I use vue-router, this warning will appear, If I not use vue-router, there's no problem,

@kuitos
Copy link
Member

kuitos commented Jul 9, 2018

@lvvlan fixed and released v2.0.7
Thanks for your feedback!

@kuitos kuitos closed this as completed Jul 9, 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

2 participants