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

Question

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

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

In many tutorials about VueJS I see this example:

import VueResource from 'vue-resource';
Vue.use(VueResource);

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

window.Vue = require('vue');
require('vue-resource')

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?

Answers to

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

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: https://vuejs.org/v2/guide/plugins.html#Using-a-Plugin

Source Show
◀ Wstecz