gpt4 book ai didi

ruby-on-rails - 如何使用 bootstrap 与 Rails 进行 react

转载 作者:行者123 更新时间:2023-12-03 13:31:13 28 4
gpt4 key购买 nike

我尝试过使用 npm 包 reactstrap。我的组件:

import { Col, Button, Form, FormGroup, Label, Input, FormText } from 'reactstrap';

我收到以下错误:

ExecJS::ProgramError at /dir/xyz
TypeError: require is not a function

最佳答案

webpacker-gem 是使用 React + Rails 的方式,而不是 sprockets ,这对于 jQuery 风格的 JS 来说是可以的,但对于复杂的基于 ES6 的堆栈来说就不行了。

来自自述文件:

To use Webpacker with React, create a new Rails 5.1+ app using --webpack=react option:

# Rails 5.1+
rails new myapp --webpack=react

(or run bundle exec rails webpacker:install:react in a existing Rails app already setup with Webpacker).

The installer will add all relevant dependencies using Yarn, changes to the configuration files, and an example React component to your project in app/javascript/packs so that you can experiment with React right away.

请注意,从那时起您将使用yarn,而不是npm。

关于ruby-on-rails - 如何使用 bootstrap 与 Rails 进行 react ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49517272/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com