bootstrap-vue / bootstrap-vue

BootstrapVue provides one of the most comprehensive implementations of Bootstrap v4 for Vue.js. With extensive and automated WAI-ARIA accessibility markup.
https://bootstrap-vue.org
MIT License
14.52k stars 1.88k forks source link

<b-nav-item> is not consistent with the to attribute rendering of the <router-link> component #4518

Closed long-woo closed 4 years ago

long-woo commented 4 years ago

Describe the bug

<b-nav-item> Theto attribute of the component does not have a # sign, and the route is invalid <router-link> component works

Steps to reproduce the bug

image

image

Expected behavior

Same result as to attribute of<router-link>.

Versions

Libraries:

Environment:

tmorehouse commented 4 years ago

<b-nav-item> passes the to prop as-is to <router-link> (<b-nav-item> is just a wrapper for <router-link> when this.$router is detected).

Do you see the same issue when using <b-link to="/task">? <b-link> is the common wrapper for <router-link> used by all components that support the to prop.

long-woo commented 4 years ago

Same question.

image

tmorehouse commented 4 years ago

It almost sounds like BootstrapVue is not detecting vue-router in your app and is converting the to prop to a plain <a> tag.

I am also assuming that you are using vue router in hash mode?

As a side note, the Bootstrap Vue docs use <b-nav-item> for the top navbar (and sidebar navigation).

tmorehouse commented 4 years ago

How are you installing Vue router? Are you injecting the router into your top level app?:

import Vue from 'vue'
import VueRouter from 'vue-router'
import { BootstrapVue } from 'bootstrap-vue'

Vue.use(VueRouter)
Vue.use(BootstrapVue)

const router = new VueRouter({
  routes: [
    { path: '/foo', component: Foo },
    { path: '/bar', component: Bar }
  ]
})

const app = new Vue({
  router
}).$mount('#app')
long-woo commented 4 years ago

The pre-upgrade version " bootstrap-vue ":" ^ 2.0.0-rc.6 " is normal.

The routing configuration is as follows:

export default new Router({
  routes: [
    {
      path: '/',
      component: Main,
      children: [
        {path: '', name: 'NewTask', component: () => import('@/views/NewTask')},
        {path: 'taskmanager', name: 'TaskManager', component: () => import('@/views/TaskManager')},
        {path: 'myorder', name: 'MyOrder', component: () => import('@/views/MyOrder')}
      ]
    }
  ]
})
jacobmllr95 commented 4 years ago

@long-woo I've created a little demo and I can't reproduce your problem: https://codesandbox.io/s/bootstrapvue-b-navbar-link-and-vue-router-ts6nb