[英]Reactjs: ReferenceError: kendo is not defined
I am using kendo-ui in my react project. 我在我的React项目中使用kendo-ui。 Code for importing and using the Menu component is as below: 导入和使用“菜单”组件的代码如下:
import React from 'react';
import { Menu, MenuItem } from '@progress/kendo-layout-react-wrapper';
const AppHeader = () => {
return (
<Menu>
<MenuItem>
Test Item
</MenuItem>
</Menu>
)
}
export default AppHeader;
It compiles fine, but throws the following error while rendering: 它可以很好地编译,但是在渲染时引发以下错误:
ReferenceError: kendo is not defined
Menu../node_modules/@progress/kendo-layout-react-wrapper/dist/es/menu/menu.js.Menu.componentDidMount
E:/projects/eucerin/node_modules/@progress/kendo-layout-react-wrapper/dist/es/menu/menu.js:31
28 | Menu.prototype.componentDidMount = function () {
29 | var domNode = ReactDOM.findDOMNode(this);
30 | var _a = this.props, children = _a.children, widgetRef = _a.widgetRef, props = __rest(_a, ["children", "widgetRef"]);
> 31 | this.widgetInstance = new kendo.ui.Menu(domNode, props);
32 | _super.prototype.componentDidMount.call(this);
33 | };
34 | Menu.prototype.componentWillReceiveProps = function (nextProps) {
I think I am missing a dependency here. 我想我在这里缺少依赖性。 Could anyone please let me know? 有人可以让我知道吗?
Thanks 谢谢
I had a similar problem and asked the questions React Kendo UI TreeView throws 'kendo is not defined' 我有一个类似的问题,并问了问题React Kendo UI TreeView抛出``未定义Kendo''
I found the solution from the KendoUI plunker example TreeView Example 我从KendoUI插件示例TreeView示例中找到了解决方案
The Kendo UI instruction is: Kendo UI指令是:
Dependencies
The TreeView package requires you to install the following peer dependencies in your application:
We have to install it but that's not enough. 我们必须安装它,但这还不够。 What KendoUI team did is import @progress/kendo-ui
in the code explicitly: KendoUI团队所做的工作是在代码中显式导入@progress/kendo-ui
kendo @progress/kendo-ui
:
import kendo from '@progress/kendo-ui';
Hope it helps. 希望能帮助到你。
I had the same problem. 我有同样的问题。 For some reason, I had to import kendo this way : 由于某种原因,我不得不以这种方式导入剑道:
import from '@progress/kendo-ui';
Hope it helps. 希望能帮助到你。
From the source , you also need 1 base dependency to use kendo-layout-react-wrapper
: 从源头来看,您还需要1个基本依赖项才能使用kendo-layout-react-wrapper
:
@progress/kendo-base-component-react-wrapper
To install and save as dependency, use: 要安装并另存为依赖项,请使用:
npm install --save @progress/kendo-base-component-react-wrapper
I think you're missing the peer dependency (@progress/kendo-ui) . 我认为您缺少对等项依赖(@ progress / kendo-ui) 。
Type npm install --save @progress/kendo-ui
in your project folder and compile your frontend again to see if it fixes the error. 在您的项目文件夹中键入npm install --save @progress/kendo-ui
,然后再次编译前端以查看它是否可以解决该错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.