如何在laravel中打包javascript文件?

时间:2016-11-18 11:36:45

标签: javascript laravel

我正在使用Laravel 5.3, 我想打包文件app.js中的所有javascript文件,我需要()tethercropper,如下所示: :

require('tether');// `tether` is put at the head of `Bootstrap`
require('./bootstrap');

require('cropper');

Vue.component('example', require('./components/Example.vue'));

const app = new Vue({
    el: 'body'
});

然后运行gulp,没关系! 但在chrome broswer的控制台中,有2个错误:

Uncaught Error: Bootstrap tooltips require Tether
Uncaught TypeError: $image.cropper is not a function

为什么?

PS:

bootstrap不是Bootstrapbootstrap.js中有resources/assets/js个文件,而Bootstrap是Twitter的用户界面。

1 个答案:

答案 0 :(得分:1)

因此,正如我在评论中所写,解决方案是遵循以下代码:

import Tether from 'tether'

window.Tether = Tether;