I have following code
JS
var vm = new Vue({
el: \'#vue-in
I fixed this issue of the following mode:
npm install bootstrap-vue --save
npm install vue-resource --save
in main.js
import Vue from './bootstrap'
import BootstrapVue from 'bootstrap-vue'
Vue.use(BootstrapVue)
create bootstrap.js
import Vue from 'vue'
import VueResource from 'vue-resource'
Vue.use(VueResource)
export { Vue }
In App.vue
this.$http.get('/api/module/all').then(...
In order to use $http you must install the vue-resource middleware first. You can use the following command to install it.
npm install vue-resource --save
After its installed go to your main.js file and import the vue resource as follows
import vueResource from 'vue-resource'
Now its imported so we just have to call the use method of Vue to work with this middleware. You can call the use method as follows.
Vue.use(vueResource)
As you have no plugin for vue-resource your this.$http is undefined. To add Vue-resource on js-fiddle add https://cdn.jsdelivr.net/g/vue@2.0.0-rc.4,vue.resource@1.0.0 to the external scripts section.
I used another way as of Oct 2019. I first installed using NPM like this
npm install axios --save
I used this below later and doing this below got rid of the error.
import axios from 'axios';
$http.get
is from Vue Resource. Make sure you are pulling that in properly by adding vue-resource
to your package.json
, install it via npm install
and in code:
var Vue = require('vue');
Vue.use(require('vue-resource'));
To use this in fiddle, you have to add vue-resource
cdn link in external resources and use following in code:
Vue.use(VueResource)
See working demo: https://jsfiddle.net/49gptnad/187/