WebDev2017-05-19 22:53:00
WebDev, 2017-05-19 22:53:00

A couple of questions about the SPA?

Hello, 2 simple questions from a newbie. I decided to learn vue.js and start building proper single page apps. I think that the js framework is not particularly important here, I'm interested in the approach.
Question 1: I have a different layout structure on different pages. For example, on the main three-column interface, on some it’s just a block with text, on some it’s a full-width horizontal menu.
Actually, as I understand it, there are two ways to manage the page:
The first way is to create one single container and initialize one vue object. More or less like this:

<div id="app"></div>

new Vue({
  el : '#app'

Inside div#app there will be page elements that I will hide/show.
The second way is to create a separate vue object for each element on the page.
Something like this:
<div id="left-menu"></div>
<div id="content"></div>

new Vue({
  el : '#left-menu'
new Vue({
  el : '#content'

Within each object, manage its state. Tell me how to do it right. In all the manuals / lessons that came across, banal cases are shown, such as show / hide the square.
Question 2: How to give the page to robots and search engines? I now do this: when requesting a page, I check the user's client, if he is from the list of robots / bots, then I give him the page, if not, then I redirect the request to index.php.
Thank you!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Yaroslav, 2017-05-19

1. There is no pattern standard in vue yet, but if it's wise, then the application should always have one main component. The component approach is very flexible and convenient. For different pages (components), use a router.
For the state, there is vuex or the same hype redux
2. It is not entirely clear who gives what to whom. At you a static from the server gives a larka? Starting from 2.3.3, ssr (side rendering server) started working right out of the box, but not all life cycle hooks are more accurately present there.

Andrey K, 2017-05-21

2. In theory, search robots can track it. Giving different pages to search engines and clients is a terrible crime in terms of SEO.
Although, maybe there is some legal way to show that this is a SPA to a search engine. I heard that there seems to be something, but not the fact that it will still work correctly.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question