Vue.js w System.js:scope.router.go错误

时间:2018-01-20 08:39:57

标签: vue.js vue-router system.js

目前正在测试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
  },
...
};

1 个答案:

答案 0 :(得分:0)

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

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

没有href =“”..

如果要将目标放到目标网页的顶部,我必须添加

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

在目标组件index.js