0

目前在将 Vue.js-System.js 应用程序移至 webpack2 之前对其进行测试,我遇到了路由模式的问题。

在我的 OPA Memberships 组件中,单击链接时,我想从路由器请求注册页面。我用了

组件/index.js

import Memberships from "components/Memberships/index";
// all the components in the OPA which are not in the routes
....
export {
  ....
   Memberships,
  ....
}

组件成员资格模板

....
<a type="button" @click="router.go('/registrations')"  href="">REGISTRATION</a>

我收到以下错误:

return  scope.router.go('/registrations');

Source map error: request failed with status 404
Resource URL: http://127.0.0.1:8080/libs/js/system.js
Source Map URL: system@0.18.17.js.map

如果我删除 href="" 那么我得到

scope.router undefined

在我的 routes/index.js 中,定义了注册路由:

路线/index.js

  import Registrations from 'routes/Registrations/index';
  export default {
    ...
    '/registrations': {
        component: Registrations
  },
...
};

4

1 回答 1

0

忘了“这个”。在 Vue.js 2 我应该使用:

@click="this.$router.go('/registrations')" 

没有 href="" ..

在 orer to scromm 到目标页面的顶部,我必须添加

ready() {
    var vm = this;
    document.body.scrollTop = document.documentElement.scrollTop = 0;
},

在目标组件 index.js

于 2018-01-20T09:10:20.317 回答