2016-11-18 155 views
3

我使用Laravel 5.3, 我要打包所有的JavaScript文件,在文件app.js,我需要()tethercropper這樣的: :如何在laravel中打包JavaScript文件?

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,沒關係! 但在鉻broswer的控制檯,有2個錯誤:

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

爲什麼

PS:

bootstrapBootstrap,存在resources/assets/js文件bootstrap.jsBootstrap是Twitter的UI。

+1

你嘗試'從「繩索」進口繫繩; window.Tether = Tether;'? – Skysplit

+0

@Skysplit謝謝,這個問題已經解決了。另一個錯誤出現:'[Vue warn]:找不到元素:body' – zwl1619

+0

@ zwl1619你使用的是Vue 2.0嗎? –

回答

1

所以,我已經寫在註釋中,該解決方案是下面的代碼:

import Tether from 'tether' 

window.Tether = Tether; 
相關問題