← Back

vue/no-shared-component-data warning

When using the data property on a component (i.e. anywhere except on new Vue), the value must be a function that returns an object.

Examples

❌  Incorrect

<script>
    export default {
        data: {
            foo: 'bar',
        },
    }
</script>

✅  Correct

<script>
    export default {
        data () {
            return {
                foo: 'bar',
            };
        },
    }
</script>