Da ich in der Anwendungsentwicklung häufig jquery verwendet habe, habe ich die Einführungsmethode zusammengefasst. ** Die Rails-Version ist 6.0.0. ** ** **
yarn add jquery
config/webpack/environment.js
const { environment } = require('@rails/webpacker')
#Nachtrag
const webpack = require('webpack')
environment.plugins.prepend('Provide',
new webpack.ProvidePlugin({
$: 'jquery/src/jquery',
jQuery: 'jquery/src/jquery'
})
)
#Bisher
module.exports = environment
app/javascript/packs/application.js
require('jquery') #Nachtrag
require("@rails/ujs").start()
require("turbolinks").start()
require("@rails/activestorage").start()
require("channels")
require("../category")
require("../category_post")
Recommended Posts