首页 > 为什么vue-router中的钩子函数没有触发?

为什么vue-router中的钩子函数没有触发?

这是我的main.js

import Vue from 'vue';
import VueRouter from 'vue-router';
import App from './App';
import Index from './views/index';

Vue.use(VueRouter);

let app = Vue.extend({
    components: { App }
});

let router = new VueRouter({
    hashbang: false
});

router.map({
    '/home': {
        name: 'home',
        component: Index
    }
});

router.start(App, '#app');

index.vue

<template>
    <p>im index</p>
</template>

<script>
export default {
    route: {
        active(transition) {
            console.log('yo im active');
            transition.next();
        },
        deactive(transition) {
            console.log('yo im deactive');
            transition.next();
        }
    }
}
</script>

<style lang="css">
</style>

切换路由的时候钩子函数没有触发,是哪里用错了吗?


亲,是activate,deactivate,不是active,deactive

【热门文章】
【热门文章】