vuejs / Discussion

Vue.js discussion
167 stars 17 forks source link

How to structure a project with multiple view models? #413

Open matteocontrini opened 9 years ago

matteocontrini commented 9 years ago

Hello, say I have an application with 5 pages (= 5 actual html files). Every page shows different things, so every page should have its corresponding ViewModel (= Vue instance).

How should I structure the files of my project? Should every VM have its own file and then every page will reference the appropriate one? Or should I bundle all the Vue definitions in a single file and then Vue itself will decide if the el option actually exists?

Thanks

mark-hahn commented 9 years ago

Should every VM have its own file

IMHO, yes.

On Mon, Sep 21, 2015 at 7:49 AM, Matteo Contrini notifications@github.com wrote:

Hello, say I have an application with 5 pages (= 5 actual html files). Every page shows different things, so every page should have its corresponding ViewModel (= Vue instance).

How should I structure the files of my project? Should every VM have its own file and then every page will reference the appropriate one? Or should I bundle all the Vue definitions in a single file and then Vue itself will decide if the el option actually exists.

Thanks

— Reply to this email directly or view it on GitHub https://github.com/vuejs/Discussion/issues/413.

yyx990803 commented 9 years ago

See http://vuejs.org/guide/application.html

matteocontrini commented 9 years ago

I've already read that page, but I couldn't find an answer or suggested strategy about my questions

yyx990803 commented 9 years ago

@matteocontrini if you have separate pages and each of your vm does different things, then yeah, one file for each vm instance.