【发布时间】:2019-02-06 20:32:55
【问题描述】:
ag-grid-vue documentation from ag-grid website 明确表示:
您可以在 Grid 中提供 Vue Router 链接,但您需要 确保为正在创建的网格组件提供路由器。
带有示例代码:
// create a new VueRouter, or make the "root" Router available
import VueRouter from "vue-router";
const router = new VueRouter();
// pass a valid Router object to the Vue grid components to be used within the grid
components: {
'ag-grid-vue': AgGridVue,
'link-component': {
router,
template: '<router-link to="/master-detail">Jump to Master/Detail</router-link>'
}
},
// You can now use Vue Router links within you Vue Components within the Grid
{
headerName: "Link Example",
cellRendererFramework: 'link-component',
width: 200
}
这里缺少的是如何使“根”路由器可用。我一直在寻找各种来源,发现很多人有同样的问题,但没有一个得到明确的答案。
https://github.com/ag-grid/ag-grid-vue/issues/1
https://github.com/ag-grid/ag-grid-vue/issues/23
https://github.com/ag-grid/ag-grid-vue-example/issues/3
https://forum.vuejs.org/t/vue-cant-find-a-simple-inline-component-in-ag-grid-vue/21788/10
ag-grid-vue 是否仍然可以与 vue-router 一起使用,那么如何使用,或者这只是过时的文档?有些人声称它对他们有用,所以我认为它在某一时刻有效。
我现在不是在寻找酷的答案。我只是想知道这是否可能。我尝试使用 window 或 created() 传递路由器,但到目前为止都没有工作。
谢谢!
【问题讨论】:
-
它可能应该以这种方式工作,但从卡在它上面的人数来看,可能有什么东西坏了。并且它需要 ag-grid 一段时间来修复它。使用这种方法可能会有更好的机会:router.vuejs.org/guide/essentials/navigation.html。使用 ag-grid
cellRenderer: stackoverflow.com/a/45231951/405015。如果这没有意义,请告诉我,我会写一个完整的答案。对于这个问题,我并没有真正使用 Vue.js,但它看起来与 React 足够相似。 -
是否有可能在另一个重叠的 dom 元素上触发了 click 事件?我也会尝试使用 Vue 的提供/注入 api。
-
@thirtydot,非常感谢。有用。我写了一个完整的答案,还有一个提示来支持右键单击行为。
-
看起来 ag-grid 已经解决了这个问题:github.com/ag-grid/ag-grid-vue/issues/1#issuecomment-430685517。
标签: vue-router ag-grid