Question: Where is Vue.use(VueResource) string in Laravel project?


Where is Vue.use(VueResource) string in Laravel project?

Answers 1
Added at 2017-01-04 14:01

In many tutorials about VueJS I see this example:

import VueResource from 'vue-resource';

But in newly created Laravel 5.3 project I found only this code (bootstrap.js file):

window.Vue = require('vue');

And found no "use" directive for vue-resource, but AJAX queries like this.$http.get() still work well. So, how Vue instance can use vue-resource?

nr: #1 dodano: 2017-01-04 16:01

vue-router doesn't require use if Vue is declared globally. From the official docs:

Some plugins provided by Vue.js official plugins such as vue-router automatically calls Vue.use() if Vue is available as a global variable. However in a module environment such as CommonJS, you always need to call Vue.use() explicitly.

In laravel, you will see that Vue is declared globally by attaching it to window like so:

window.Vue = require('vue');

So the use is not required.


Source Show
◀ Wstecz