As a newcomer to Vue.js, I recently attempted to incorporate vue-resource into my project only to encounter the following 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
The versions I am using are Vue 3.0.7 and vue-resource 1.5.2
Upon inspecting the vue-resource source code located in
node_modules/vue-resource/dist/vue-resource.js
, I found this snippet at line 1469:
if (typeof window !== 'undefined' && window.Vue && !window.Vue.resource) {
window.Vue.use(plugin);
}
When testing window.Vue
in the browser console at localhost:3000
, it was defined but window.Vue.use
was not.
At the end of my index.html
file, the script tags include:
<!--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>
In my methods property, the onSubmit() method for utilizing vue-resource is defined as follows:
onSubmit() {
console.log("Search");
let path = "/search?q=".concat(this.search);
this.$http.get(path)
.then(response => {
console.log(response);
});
}