Hacker News new | ask | show | jobs
by armaxt 2772 days ago
How about the ability to create multiple components in the same .vue file? for instance I need to define a sub-component that will be used only inside my component, this is easy in React but with Vue I have to create another file to define this sub-component, this makes the project management becomes harder as the project grows
3 comments

That is one of the few aspects I prefer in React over Vue.

But you can indeed create small inline components in .vue files.

There are different approaches: https://codewithhugo.com/writing-multiple-vue-components-in-...

This is totally possible. You can create a sub component, register and use it in the same file as the parent component. Though not really recommended you can even do this:

  ...
  components: {
    "inline": {
      template: `
        <h1>My inline subcomponent</h1>
      `
    }
  }
  ...
>How about the ability to create multiple components in the same .vue file?

No problem: https://www.youtube.com/watch?v=l3GHggI3_z8

As you can see, the're quite a few nested components in a single .vue file.