FranckFreiburger / http-vue-loader

load .vue files from your html/js
MIT License
1.49k stars 275 forks source link

httpVueLoader is not defined Using httpVueLoader from vue + Webpack #37

Closed mdeolmos closed 5 years ago

mdeolmos commented 6 years ago

This is more a question than a bug.

I'm trying to use httpVueLoader from a component in vue, But for some reason httpVueLoader is not defined.

`import Vue from 'vue'; import httpVueLoader from 'http-vue-loader';

Vue.use(httpVueLoader);

export default { data() { }, components: { Modal, }, mounted() { console.log(JSON.stringify(httpVueLoader('myurl'))); //httpVueLoader is not defined this.loadInfo(); },`

ReferenceError: httpVueLoader is not defined at eval (eval at mounted (webpack-internal:///518), :1:1) at VueComponent.mounted (webpack-internal:///518:52:5) at callHook (webpack-internal:///4:2825:21) at Object.insert (webpack-internal:///4:4029:7) at invokeInsertHook (webpack-internal:///4:5777:28) at Vue$3.patch [as patch] (webpack-internal:///4:5985:5) at Vue$3.Vue._update (webpack-internal:///4:2570:19) at Vue$3.updateComponent (webpack-internal:///4:2698:10) at Watcher.get (webpack-internal:///4:3041:25) at new Watcher (webpack-internal:///4:3030:12)

Do you know what could be wrong?

sp00x commented 6 years ago

I have the exact same question.

As a hack I ended up copying the http-vue-loader.js file from the node_modules directory to my /static dir and including it from there. (I am hopeless at webpack, so I am sure there is an elegant way of including it from node_modules and getting it bundled, but I couldn't figure out how)

tartinesKiller commented 6 years ago

Hello, It seems there is a typo error: module.export instead of module.exports

This commit https://github.com/imachug/http-vue-loader/commit/5f39925eb29c25e530dd9194e76c5e8c8f2b6dd5 from this fork https://github.com/imachug/http-vue-loader fix this bug.

So, in my package.json, I've replaced the original http-vue-loader with: "http-vue-loader": "git+https://git@github.com/imachug/http-vue-loader.git#5f39925eb29c25e530dd9194e76c5e8c8f2b6dd5", (I use this specific commit because it seems there is some other changes in the next commits).

Then, I can do without any problem: import httpVueLoader from "http-vue-loader";

FranckFreiburger commented 6 years ago

typo fixed in https://github.com/FranckFreiburger/http-vue-loader/commit/cf219e09981d1de1b830025b32932dada3f9172d