2

我正在尝试使用 react-select 组件(https://github.com/JedWatson/react-select)并在阅读文档时与这句话混淆,见下文:

Be sure to include styles at some point, probably during your bootstrapping
import 'react-select/dist/react-select.css';

当我在使用 Select 组件的 React JSX 文件中导入这一行时,我收到以下错误:

 ...node_modules/react-select/dist/react-select.css:8\n.Select 
    {\n^\nParseError: Unexpected token\n>",
    "traces": {
    "Application Trace": [
    {
      "id": 39,
    "trace": "app/views/layouts/application.html.erb:7:in 

 `_app_views_layouts_application_html_erb___377503645297909977_70313107001300'"
}
],
"Framework Trace": [
{
"id": 0,
"trace": "browserify-rails (3.3.0) lib/browserify-rails/browserify_processor.rb:220:in `run_browserify'"
},
{
"id": 1,
"trace": "browserify-rails (3.3.0) lib/browserify-rails/browserify_processor.rb:51:in `call'"
},
{
....
}

有人可以就这个问题提供一些提示吗?

4

1 回答 1

2

看起来我找到了这个问题的答案。

基本上我所做的是我手动将 css 文件从 node_modules/react-select/dist/react-select.css 复制到我的 rails 项目的 /assets/javascript/stylesheets 文件夹中。

有关更多信息,请查看:https ://stackoverflow.com/a/10291177/5761338

于 2017-09-16T06:15:58.083 回答