[Vuejs]-Can't access vue-resource's $http methods from components in 2.0RC

0👍

I got an answer over on the Vue Help forum. The issue arose because I was using the standalone version of Vue but not fully aliasing it in Webpack, so Webpack was loading two different versions.

User LinusBorg answered:

You require the standalone build, but webpack is also loading the
runtime-only build, so you end up with two versions of Vue in your
project – one has vue-resource, the other doesn’t.

If you want to keep the standalone build, you have to add an alias to
your webpack config: vue: 'vue/dist/vue'

Just in case anyone else has this problem and is as generally bewildered by webpack as I am, to be slightly more explicit:

Webpack was loading two different versions of vue.js, one from my in-file import statements, one from the webpack *.vue module loaders. The exact way I fixed it was to add the following to my webpack-config.js:

resolve: {
    alias: {vue: 'vue/dist/vue.js'}
},

Within my app.es6 file I also had to change back the import Vue from 'vue/dist/vue.js' to import Vue from 'vue'.

Leave a comment