3

I am using Laravel 5.3, I want to pack all the javascript files,in file app.js,I require() tether and cropper like this: :

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'
});

Then running gulp,it's ok! But in console of chrome broswer,there are 2 errors:

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

Why is it?

PS:

bootstrap not Bootstrap,there is a file bootstrap.js in resources/assets/js,and Bootstrap is the UI of Twitter.

7
  • 1
    Did you try import Tether from 'tether'; window.Tether = Tether;? Commented Nov 18, 2016 at 12:13
  • @Skysplit Thanks,that issue has been solved.Another error appears: [Vue warn]: Cannot find element: body Commented Nov 18, 2016 at 12:36
  • @zwl1619 Are you using Vue 2.0? Commented Nov 18, 2016 at 12:47
  • @Gerard Reches yes, Vue 2.0. Commented Nov 18, 2016 at 12:57
  • 2
    @zwl1619 Then you must create a wrapper div with an id. <body><div id="app">Your page</div></body> and change el: 'body' to el: '#app'. In Vue 2.0 html or body can't be used for el. Commented Nov 18, 2016 at 13:07

1 Answer 1

1

So, as I have written in comments, the solution is following code:

import Tether from 'tether'

window.Tether = Tether;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.