新手问题 Rails 项目初始引入 Bootstrap 方法

LPFpengfei · July 13, 2017 · Last by Fighting_3 replied at May 18, 2018 · 5118 hits

rails 创建一个新项目,引用前端框架 boostrap 方法是这样的吗? 1.rails new blog 创建一个新项目。

2.在新建项目中添加两个 gem。

gem 'jquery-rails'
gem 'bootstrap', git: 'https://github.com/twbs/bootstrap-rubygem'

3.bundle install 并重新启动服务器

4.新建项目中 app / assets / stylesheets 中 application.css 后缀为.css,因此将后缀改为.scss。 删除其中自动生成内容,添加下面语句

@import "bootstrap";

5.在 application.js 中添加下列语句

// = require jquery3 
// = require popper 
// = require bootstrap

jquery 必须在 bootstrap 前面 require

6.重启服务器即可

ps:我是根据 Ruby China 常用 Gem 中Boostrap这个来添加的,具体呢也实现了,就是不是到这样的操作符不符合规范。新人不太懂,网上的引入方法五花八门的,有点拎不清。。。

不对的地方请大神指正!!!!万分感谢!!!!

忽然发现还是不对,引入之后样式还是无法加载。。。。。到底哪里错了呢?

我去,被你坑

Reply to kikyous

2 楼正解,官方文档写的很清楚

LPFpengfei closed this topic. 29 Jan 16:40
You need to Sign in before reply, if you don't have an account, please Sign up first.