I tried to use vue-resource and I got "Uncaught TypeError: window.Vue.use is not a function"

375 Views Asked by At

I am new to Vue.js and recently, I tried to use vue-resource but I get this error:

Uncaught TypeError: window.Vue.use is not a function
   at vue-resource.js:1469
   at vue-resource.js:10
   at vue-resource.js:11 

I am using Vue 3.0.7 and vue-resource 1.5.2

I tried to look for the error in the vue-resource source code in node_modules/vue-resource/dist/vue-resource.js and there was this block of code at line 1469:

    if (typeof window !== 'undefined' && window.Vue && !window.Vue.resource) {
      window.Vue.use(plugin);
    }

I tried writing window.Vue in the browser console of localhost:3000 and it was defined but window.Vue.use wasn't.

this is the end of the body tag of my index.html file:

<!--some code -->
  <!-- Scripts -->
  <!-- adding hot reload -->
  <script src="/reload/reload.js"></script>
  <script src="node_modules/vue/dist/vue.global.js"></script>
  <script src="node_modules/vue-resource/dist/vue-resource.js"></script>
  <script src="public/script.js"></script>

</body>

</html>

This is the method I have defined in the methods property to use vue-resource :

            onSubmit() {
                console.log("Search");
                let path = "/search?q=".concat(this.search);
                this.$http.get(path)
                    .then(response => {
                        console.log(response);
                    });
            }
1

There are 1 best solutions below

0
YSLCode On

Well, I found out that vue-resource doesn't support vue3. It is written in npmjs.com that: Supports Vue 1.0 & Vue 2.0. And vue3 isn't mentioned.