dongliping003116 2018-07-13 04:53
浏览 74

模块在Laravel 5.6中不起作用

I have a problem with webpack.mix in laravel, my modules are not being recognized, i did some research for figuring out what could be happening:

This is my app.js file from resources/assets/js

console.log('Test');
require('imagesloaded')
require('jquery')
require('slick-carousel')

In the console i see 'Test', but all the other modules are not recognized, in public/js i have the init files for each module but is not working, i even try this in webpack.mix.js:

mix.js('resources/assets/js/app.js', 'public/js')
   .sass('resources/assets/sass/app.scss', 'public/css')
   .extract([
       'jquery',
       'slick-carousel',
       'imagesloaded'
    ])
    .options({
       uglify: true,
    })

And importing vendor.js.

I also tried initializing the modules in the app.js file, for initializing i mean just slick(), i also tried giving each require a variable name, and using syntax import "modulename", but nothing...

Any ideas of what could be happening?

After some trial and error with DigitalDrifer this is the app.js file working

import $ from 'jquery'
const imagesLoaded = require('imagesloaded')
const slick = require('slick-carousel')

With all the code for initializing each package inside app.js (below requiring), not in different folders, according to this that is a bad practice anyways.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 双层网络上信息-疾病传播
    • ¥50 paddlepaddle pinn
    • ¥20 idea运行测试代码报错问题
    • ¥15 网络监控:网络故障告警通知
    • ¥15 django项目运行报编码错误
    • ¥15 请问这个是什么意思?
    • ¥15 STM32驱动继电器
    • ¥15 Windows server update services
    • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
    • ¥15 模糊pid与pid仿真结果几乎一样