D
D
Dauren S2020-10-05 09:42:32
CRUD
Dauren S, 2020-10-05 09:42:32

What is the best way to write in Vue?

I make pages on vue
Create Edit Index View
How best to make everything in different views?
Or is it all in one Index component and rendering changes depending on the router?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Yarkov, 2020-10-05
@yarkov Vue.js

Better in different ones, otherwise you will get confused in logic and template.
Make a hierarchy like this:

/articles/index.vue - просмотр списка статей
/articles/create.vue - создать статью
/articles/view.vue - смотреть статью
/articles/edit.vue - редактировать статью

And routes:
{path: '/articles', component: './articles/index.vue'}
{path: '/articles/create', component: './articles/create.vue'}
{path: '/articles/:id', component: './articles/view.vue'}
{path: '/articles/:id/edit', component: './articles/edit.vue'}

This is purely personal opinion and does not claim to be the only correct one.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question