W
W
WebDev2018-06-15 11:50:31
Vue.js
WebDev, 2018-06-15 11:50:31

How to use Vue.set in mixins?

Hello, I decided to move the update method to the mixin and connect it to different components.
The mixin code is:

const $ = require('jquery');
const _ = require('lodash');
const config = require('@/config');
const Vue = require('vue');

module.exports = {
    manageMixin: {
        data: function () {
            return {
            }
        },
        methods: {
            update: function() {
                //some code
                Vue.set(this.data, 'links', result.data.links);
            }
        }
    },
};

Now I include it in the component:
import {manageMixin} from '@/mixins/manage'

export default {
    ...
    mixins: [manageMixin],
    ...
}

Now my component has an update method from the mixin available, but using Vue.set throws the error Vue.set is not a function.
What am I doing wrong?
UPD: Vue.default.set works instead of Vue.set, but something tells me that this is wrong.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2018-06-15
@kirill-93

Replace with
const Vue = require('vue');
const Vue = require('vue').default;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question