LoginSignup
0
0

More than 3 years have passed since last update.

RailsにVue.jsを導入する準備

Posted at

はじめに

バージョン
Ruby '2.6.5'
Rails '6.0.3'
Vue.js '2.6.11'

Railsは6.0以降。

Vue.jsの導入

Webpackerを用いてインストール

ターミナル
rails webpacker:install:vue

Vue.jsを読み込む

app/view/layouts/application.html.erb
<!DOCTYPE html>
<html>
  <head>
    <title>Title</title>
    <%= csrf_meta_tags %>
    <%= csp_meta_tag %>

    <%= stylesheet_link_tag 'application', media: 'all' %>
    <%= javascript_pack_tag 'application' %>
  <%# 以下の一行を追加 %>
    <%= javascript_pack_tag 'hello_vue' %>
  </head>

  <body>
    <%= yield %>
  </body>
</html>

localhost:3000へアクセスして、"Hello Vue!"と表示されていれば、
導入と読み込みは上手くいっています。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0