简体   繁体   English

如何在React组件中使用npm包javascript

[英]how to use npm package javascript inside react component

I am trying to use rc-calender in react. 我试图在反应中使用rc-calender。
https://www.npmjs.com/package/rc-calendar https://www.npmjs.com/package/rc-calendar
I need to use css for this package. 我需要为此包使用css。
I am trying to use this as follows. 我正在尝试如下使用。

require('rc-calendar/assets/bootstrap.css');

But it is giving me 但这给了我

ParseError : Unexpected token. ParseError :意外令牌。

I am getting similar error for all other css(from other npm packages). 我从其他npm包中得到所有其他css的类似错误。

Any idea how to use these CSS. 任何想法如何使用这些CSS。

I guess you're using webpack. 我想您正在使用webpack。 Is require('rc-calendar') alone loading ? 是require('rc-calendar')单独加载吗?

Check that first maybe. 首先检查一下。 Then check the path in your npm-module maybe you have a newest version of the module and the path in the tutorial you followed is wrong. 然后检查npm-module中的路径,也许您拥有该模块的最新版本,并且遵循的教程中的路径错误。

hope it helps 希望能帮助到你

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

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