Vue: RequireJS example

Created on 9 Nov 2014  ·  10Comments  ·  Source: vuejs/vue

[Enhancement]

Would it be possible to provide a CommonJS example (with RequireJS for instance) ?
I am just learning how to use Vuejs, and I'm a bit lost with nested components and the events triggering system : my parent element does not catch the events emitted by its components.

Maybe an example would help to understand the good ways and tips to start writing reusable components with CommonJS ?

All 10 comments

Hi Flo-Schield-Bobby,

You can have a look at that link : https://github.com/hwclass/vuejs-custom-component-bootstrap. I have developed that example with the component library. This is just a boilerplate to develop something else with them all..

Good luck..

Hi @hwclass, thanks a lot, I'll take a look right now !

RequireJS uses AMD rather than CommonJS. However there is a basic CommonJS based example using Browserify: https://github.com/vuejs/vue-browserify-example

I missed all those examples, sincerely sorry for this question... And thanks !

Maybe would it just be interesting to merge them in the official vuejs repo ? If I am not the only-one to miss them ?

It can be closed, however !

They are mentioned on the documentation site: http://vuejs.org/guide/application.html

going back to the title of the issue.. Can vue.js be used together with require.js?

@Gamadril Does this question have an answer? Can vue.js be used together with require.js? Thanks!

@cmal Yes, it can. Why wouldn't it? Although, I'd recommend you to use other bundlers like webpack.

@posva Hi, I'm currently having a problem using vue.js with requirejs. If I add vue.js as a html tag, requirejs will props an error which described in http://requirejs.org/docs/errors.html#mismatch . I've followed the instructions given there but no result. I use jquery the same way but no problem, but vue cannot. MISMATCHED ANONYMOUS DEFINE() MODULES ... Can you give me some opinions about how I can deal with that? Or are there any examples that successed with using vue.js in require.js? Thank you very much!

@cmal Sorry, last time I used requirejs was 3 years ago. I recommend you to use something else for bundling like webpack. You can start from this: https://github.com/vuejs-templates/webpack
Remember you should post question on the forums
I'm locking this now to keep it quiet 🙂

Was this page helpful?
0 / 5 - 0 ratings