刷新后Nuxt.js双链接

时间:2018-02-08 21:39:48

标签: vue.js nuxt.js

当它生成生产代码宽度时,npm run generate'我有错误。

在本网站http://vue.wmcreation.pl/about

当我刷新页面nuxt添加到boostrap导航链接/ about / about。

     <b-navbar toggleable="md">

          <b-navbar-toggle target="nav_collapse"></b-navbar-toggle>

          <b-navbar-brand :to="{ path: '/' }">#jwcreation</b-navbar-brand>

          <b-collapse is-nav id="nav_collapse">

            <b-navbar-nav class="center">

              <b-nav-item :to="{ path: '/' }">home</b-nav-item>
              <b-nav-item :to="{ path: 'about' }">about</b-nav-item>
            </b-navbar-nav>

            <!-- Right aligned nav items -->
            <b-navbar-nav class="right">
              <b-nav-item :to="{ path: 'test' }">hello@jwcreation.pl</b-nav-item>

            </b-navbar-nav>

          </b-collapse>
        </b-navbar>

1 个答案:

答案 0 :(得分:1)

您的about路径必须是绝对路径,否则会累积当前路径:

<b-nav-item :to="{ path: '/about' }">about</b-nav-item>

另一种方法是通过名称页面约定

定义您的about链接
<b-nav-item :to="{ name: 'about' }">about</b-nav-item>

例如
pages/test.vue =&gt; name: 'test'
pages/parent/child.vue =&gt; name: 'parent-child'
pages/parent/yolo/index.vue =&gt; name: 'parent-yolo'