javascript - How vue-cli extracts public methods and applies them
習慣沉默
習慣沉默 2017-06-26 10:50:30
0
1
939

How to extract the method in the picture and make it into a public part

習慣沉默
習慣沉默

reply all(1)
给我你的怀抱

Write this in methods when instantiating Vue in main.js, and then call $root.link when calling it elsewhere.

var app = new Vue({
    el: '#app',
    router,
    components: {App},
    template: '<App />',
    methods: {
        link: function(to) { ... }
    },
    ...
});

It’s not written in App.vue, thank you @kokradoc for the correction.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template