8
Wombat
6y

import answer from "./knowledge.js"

const topic = 'Vue'
const rant = false
const allowDumbAnswers

const q = 'Why to use only a single Vue instance?'

allowDumbAnswers ? return : answer(q);

Comments
  • 3
    Good question, i usually use 3-4, always one for the menu
  • 2
    @sharktits I intuitively created an extra instance for my navigation, too. But still I can't get a reason why I shouldn't create an instance for every section of my page.
  • 2
    If you are not going for single page app, nothing wrong with having multiple instances.
  • 0
    @CurseMeSlowly but why it's a not to do on SPAs then?
  • 0
    @Divisionbyzero state management
  • 1
    @Hammster maybe tell me more?
  • 1
    Is there a non-hacky mechanism for communicating between the different instances?
  • 1
    @freakko
    OtherVueInstance.myLittleDataMember
  • 1
    @Divisionbyzero IMO Vue is very modular. It's like a house. Vue instance is the building. Then you have your components like rooms, partitions. Each components can also have components like tables, chairs, beds. And you can move them around if you want. But for one single building/apartment, it should just be single house. If you wanna make two or three houses under same roof, it's possible but ugly.

    So think you got enough with my metaphor skill. And here is probably better and more technical answer.

    https://laracasts.com/discuss/...
Add Comment