简体   繁体   English

如何使匿名函数库与Webpack一起运行

[英]How to get anonymous function library running with webpack

I'm trying to get this module: https://github.com/marcj/css-element-queries embedded in a ReactJS app that I have. 我正在尝试获取此模块: https : //github.com/marcj/css-element-queries嵌入到我拥有的ReactJS应用程序中。

Unfortunately if I run: 不幸的是,如果我运行:

import {ElementQueries,ResizeSensor} from 'css-element-queries';

at the top of my app, nothing happens. 在我的应用程序顶部,没有任何反应。 Any ideas? 有任何想法吗?

Update 更新

To clarify what I mean. 为了澄清我的意思。 The library doesn't appear to get triggered when the browser loads as it's supposed to. 当浏览器按预期加载时,似乎未触发该库。 However if I load the console and type ElementQueries.init(); 但是,如果我加载控制台并键入ElementQueries.init(); it works. 有用。

If I put that in the React component though I get the following error: 如果我把它放到React组件中,会出现以下错误:

_cssElementQueries.ElementQueries.init is not a function

have you tried: import 'css-element-queries'; 您是否尝试过: import 'css-element-queries';

And then access ElementQueries or ResizeSensor as a global? 然后以全局方式访问ElementQueriesResizeSensor

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM