Skip to content

The property hasn't been observed if no explicit set and the data() method provided. #1071

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
TerenceZ opened this issue Jul 23, 2015 · 0 comments

Comments

@TerenceZ
Copy link

I'm sorry I cannot provide a jsfiddle example (because I cannot find the cdn / rawgit for the latest dev code), instead here is the code I test on my machine with the latest dev vue (latest commit: eb95383).

<div id="app">
    <my-comp></my-comp>
</div>

<script>
new Vue({
    el: '#app',
    components: {
        'my-comp': {
            template: '<div>{{a}} - <input type="checkbox" v-model="a"></div>',
            replace: true,
            props: {
               a: {
                   default: false,
                   type: Boolean
               }
            },
            data() {
                return {
                    b: 123
                };
            }
        }
    }
});
</script>

In the above example, the v-model won't update the view's value.
In the above example, the v-model will update the model's value, but the model's value won't trigger the view to update because the model's value is not proxied.

The problem is that the initProp will set the default prop value on the vm, not an observable, and the _initData won't observe them also in some situation. Here is the cases:

  1. data() (also means no data options for instance) not supplied: because the _data is still the propsData, so the data will always be proxied even if it's no explicit set.
  2. data() supplied: the __data will be set to the optionsData, it will only proxy the optionsData, which means when the unproxied property value changes, nothing will be sync.
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

1 participant