1
私は、マテリアライズCSSフレームワークでsymfonyアプリケーションを作ろうとしています。公式の3.3文書によると、私はフロントエンドにアンコールを使用しています。symfony 3.3 frontend stack with encore - グローバルにjqueryプラグイン
グローバルにjqueryプラグインに問題があります。私はとglobal.jsを含むてる vendor.js で
var Encore = require("@symfony/webpack-encore");
var webpack = require('webpack');
Encore
.setOutputPath('web/build/')
.setPublicPath('/build')
.cleanupOutputBeforeBuild()
.autoProvidejQuery()
.createSharedEntry('vendor', [
'materialize-css',
'./assets/js/global.js',
])
.addStyleEntry('global', './assets/scss/global.scss')
.addEntry("createProfileModule", "./assets/js/modules/createProfile.js")
.enableSassLoader()
.enableSourceMaps(!Encore.isProduction())
.enableVueLoader()
.addPlugin(new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
'window.jQuery': 'jquery',
Popper: ['popper.js', 'default'],
// In case you imported plugins individually, you must also require them here:
Util: "exports-loader?Util!bootstrap/js/dist/util",
Dropdown: "exports-loader?Dropdown!bootstrap/js/dist/dropdown",
}))
.enableVersioning()
;
module.exports = Encore.getWebpackConfig();
:...だから...まだ動作していない マイWebPACKのコンフィグを
を Webpack Encore - jQuery plugins out of viewし、この:私はこれを試してみましたよ:
$(document).ready(() => {
$('.modal').modal();
$(".modal .close-btn").on("click",() => {
$('.modal').modal('close');
});
$(".button-collapse").sideNav();
$("#registerModal form").submit((e) => {
e.preventDefault();
$(".modal .progress").fadeIn().promise().done(() => {
setTimeout(() => {
window.location = "/stworz-profil";
}, 2500)
})
});
});
このファイルでは、jqueryプラグインは正常に動作します。
$('input.autocomplete').autocomplete({
data: {
"Gdańsk": null,
"Gdynia": null,
"Sopot": null,
"Warszawa": null,
},
limit: 20,
onAutocomplete: function(val) {
},
minLength: 1,
});
と私はコンソールにページをロードしていたとき、私は以下を参照してください:
グローバルプラグインでjQueryのを提供するために、どのようにUncaught TypeError: $(...).autocomplete is not a function
at Object../assets/js/modules/createProfile.js (createProfileModule.61543364cceab7b76d2b.js:13)
at __webpack_require__ (manifest.d41d8cd98f00b204e980.js:55)
at webpackJsonpCallback (manifest.d41d8cd98f00b204e980.js:26)
at createProfileModule.61543364cceab7b76d2b.js:1
?createProfile.jsで