Error in the console
你好啊
我是一个编程初学者,我正在使用Webpack Encore管理我的资产。我在Firefox控制台中遇到了jQuery的问题:未捕获引用错误:jQuery没有定义。
这是应用程序。js文件内容:
/*
* Welcome to your app's main JavaScript file!
*
* We recommend including the built version of this JavaScript file
* (and its CSS file) in your base layout (base.html.twig).
*/
// any CSS you import will output into a single css file (app.css in this case)
import './styles/app.scss';
// start the Stimulus application
import './bootstrap';
const $ = require('jquery');
// this "modifies" the jquery module: adding behavior to it
// the bootstrap module doesn't export/return anything
// importer sur le js de bootstrap https://symfony.com/doc/current/frontend/encore/bootstrap.html#importing-bootstrap-javascript
require('bootstrap');
require('@fortawesome/fontawesome-free/js/all.js');
// import JS de revolution slider
import './custom/js/rs6.js';
/**
* help for import Js with webpack
*/
setREVStartSize({ c: 'rev_slider_1_1', rl: [1240, 1024, 778, 480], el: [800, 550, 500, 450], gw: [1390, 1024, 778, 480], gh: [800, 550, 500, 450], type: 'standard', justify: '', layout: 'fullwidth', mh: "0" });
var revapi1,
tpj;
function revinit_revslider11() {
$(function () {
tpj = jQuery;
revapi1 = tpj("#rev_slider_1_1");
if (revapi1 == undefined || revapi1.revolution == undefined) {
revslider_showDoubleJqueryError("rev_slider_1_1");
} else {
revapi1.revolution({
sliderLayout: "fullwidth",
visibilityLevels: "1240,1024,778,480",
gridwidth: "1390,1024,778,480",
gridheight: "800,550,500,450",
spinner: "spinner0",
perspectiveType: "local",
keepBPHeight: true,
editorheight: "800,550,500,450",
responsiveLevels: "1240,1024,778,480",
progressBar: { disableProgressBar: true },
navigation: {
onHoverStop: false
},
fallbacks: {
allowHTML5AutoPlayOnAndroid: true
},
});
}
});
} // End of RevInitScript
var once_revslider11 = false;
if (document.readyState === "loading") { document.addEventListener('readystatechange', function () { if ((document.readyState === "interactive" || document.readyState === "complete") && !once_revslider11) { once_revslider11 = true; revinit_revslider11(); } }); } else { once_revslider11 = true; revinit_revslider11(); }
作为一个初学者,如果有人能帮助我确定这个错误的原因以及如何解决它,我将非常感激。先谢谢你了!
我试图为Revolution Slider*******加载JavaScript,以使滑块能够响应所有必要的屏幕格式。
我希望滑块能够根据正在观看的设备的屏幕大小和分辨率自动调整其大小和布局。但是,由于未捕获的引用错误:jQuery未定义错误,滑块功能不正常,我无法达到预期的响应。
1条答案
按热度按时间rsl1atfo1#
你需要jquery,并将其分配给$const。jQuery对象不会自动导入。要解决您的问题,请执行以下操作:
const $ = jQuery = require('jquery');
或将
tpj = jQuery;
更改为tpj = $;