Rail6-Webpack jQuery конфигурация для выпадающего меню navbar 0 Ferran · Лекция 42 · минуту назад Rails версия 6.0.2.2
Ruby версия ruby 2.7.1
app / javascript / packs / javascript. js
require ("@ rails / u js"). start ()
require ("turbolinks"). start ( )
require ("@ rails / activestorage"). Start ()
require ("channel")
require ("jquery")
import '../css/application'
import' materialize-css / dist / js / materialize '
import' material-design-icons '
$(document).on('turbolinks:load', function() {
$(".dropdown-trigger").dropdown();
})
app / views / layout / application. html .erb
<li><a class="dropdown-trigger" href="#!" data-target="dropdown1">Usuari<i class="material-icons right">arrow_drop_down</i></a></li>
$ добавление пряжи jquery
config / webpack / environment. js
const webpack = require('webpack')
environment.plugins.prepend('Provide',
new webpack.ProvidePlugin({
$: 'jquery/src/jquery',
jQuery: 'jquery/src/jquery'
})
)