是否可以在没有构建器的情况下将 ag-grid 与 vue 一起使用?

Oct*_*9on 2 ag-grid vuejs2

特别是,ag-grid-vue 组件的 typescript 源可以编译然后包含在常规 html 文件中吗?

小智 6

我找到了一种无需修改源代码即可做到这一点的方法。在 ag-grid-vue.umd.js 顶部附近,您可以看到该模块执行以下操作:

root["ag-grid-vue"] = factory(root["Vue"], root["agGrid"]);
Run Code Online (Sandbox Code Playgroud)

这里,“root”是窗口,工厂调用的结果就是您想要的。但由于破折号,您无法直接访问它。但您可以使用字典语法(或任何名称):

let agVueObj = window["ag-grid-vue"];
//The component is a field on this object:
let AgGridVue = agVueObj.AgGridVue;
//Then register it as a component in your Vue instance:
//components: { AgGridVue }
Run Code Online (Sandbox Code Playgroud)

而且您应该能够使用<ag-grid-vue>标签。