我正在尝试在angular1项目中使用ag-grid [英] i'm trying to use ag-grid in angular1 project

查看:185
本文介绍了我正在尝试在angular1项目中使用ag-grid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Jhipster入门版中进行了angular 1项目。
我对ag-grid组件有一些问题。

I'm in Jhipster starter with angular 1 project. I have some problems withe ag-grid component.

第一个:
i对我的所有组件都使用bower,wiredep包含我的ag-grid文件在angular.js文件之前。
我想我可以通过使用覆盖来解决此问题,但是我不确定
是在bower.json中的覆盖上设置的。

first one: i use bower for all my component and wiredep include my ag-grid file before the angular.js file. I think i solve this by using overrides, but i'm not sure of me I set this on overrides in bower.json.

"ag-grid": {
  "dependencies": {
    "angular": "*"
  }
}

ag-grid现在在angular.js之后就很好了,但我仍然有另一个问题。

ag-grid is well after angular.js now but i still have an other problem.

在我的控制台中,我遇到了这个 Uncaught ReferenceError:未定义的需求
,原因是bower_components / ag-grid / main.js
代码在这里:

in my console i have this "Uncaught ReferenceError: require is not defined" cause by the bower_components/ag-grid/main.js code here :

var populateClientExports = require('./dist/lib/clientExports').populateClientExports;

populateClientExports(exports);

populateClientExports(exports);

i不知道会发生什么,如果是我的替代无法正常工作或其他原因。

i don't know what happen, if it's my override not working or something else.

感谢您的帮助。

推荐答案

首先,改写应该是正确的。您可以简单地检查覆盖,如果您查看index.html并检查所包含脚本的顺序。

First, the override should be correct. you can simply check the override, if you look into the index.html and check the order of the included scripts.

第二,ag网格使用commonjs加载文件。但是Jhipster不使用常见的js。因此,您必须使用ag网格的非commonjs版本。如果我对文档的快速浏览是正确的,则必须使用另一个版本的AG网格。为此,您必须覆盖bower.json中的主文件,以便wiredep将选择此文件。因此,这

Secondly, ag grid uses commonjs to load the files. But Jhipster does not use common js. so, you have to use the non-commonjs version of ag grid. If my quick view into the docs are right, you must use another version of ag grid. For this, you have to override the main file in your bower.json, so wiredep will pick up this one. Therefore, this

"ag-grid": {
   "dependencies": {
    "angular": "*"
  },
  "main": [
   "dist/ag-grid.js"
  ]
}

应加载非通用js版本

这篇关于我正在尝试在angular1项目中使用ag-grid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆