【问题标题】:Using vue-router, how can I make menu selected styles?使用 vue-router,如何制作菜单选择样式?
【发布时间】:2016-05-01 22:02:20
【问题描述】:

我正在使用 vue 路由器来创建单页应用程序。我有一个导航系统,单击菜单项会将它们带到相应的页面。例如:

var pageView = require('./components/pageView.vue')

// Define some components
var Boards_page = Vue.extend( {
    template: '<p>Boards</p>'
})

var Fantheories = Vue.extend( {
    template: '<p>Character</p>'
})

// The router needs a root component to render.
// For demo purposes, we will just use an empty one
// because we are using the HTML as the app template.
// !! Note that the App is not a Vue instance.
var App = Vue.extend({})

// Create a router instance.
// You can pass in additional options here, but let's
// keep it simple for now.
var router = new VueRouter({
    history: true
})

// Define some routes.
// Each route should map to a component. The "component" can
// either be an actual component constructor created via
// Vue.extend(), or just a component options object.
// We'll talk about nested routes later.
router.map({
    '/': {
        component: pageView
    },
    '/boards': {
        component: Boards_page
    },
    '/fantheories': {
        component: Fantheories_page
    }
})

// Now we can start the app!
// The router will create an instance of App and mount to
// the element matching the selector #app.
router.start(App, '#container')

如何使我在菜单项上的任何 URL 都具有不同的 CSS 样式,使其看起来好像被选中?

【问题讨论】:

    标签: javascript php vue.js


    【解决方案1】:

    路由器选项linkActiveClass 确定应用于活动链路的类。默认为v-link-active

    http://vuejs.github.io/vue-router/en/options.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-03-05
      • 2022-12-16
      • 2013-11-15
      • 2020-10-31
      • 1970-01-01
      • 1970-01-01
      • 2012-09-05
      相关资源
      最近更新 更多