Can php data be directly exported to template in the. vue component for server-side rendering of pages?

  node.js, question
  • Learnvue-loader-exampleAfter the example, I plan to use this as the front end in the laravel framework, but I find that php data cannot be directly output in the. vue component as before, or what should I do?

  • Is it not directly used.vueSingle file components, likevue-webpack-exampleAs in, can php data be directly used in page templates by separating the three types of files? (Naturally, I know that this is not conducive to separation, and I want to change step by step in view of the current learning situation.)

  • If ajax is used to obtain all the data, even the full page refresh is obtained through secondary request, isn’t it bad?

  • If the front and back ends are separated instead of SPA, is it better to get api on the node layer to render the page, and can the data obtained from the Node layer be directly handed over to the. vue component for page rendering?

  • Then there is the problem of SPA, SEO have a better solution? Are there currently PJAX and Search Engine Optimization plans?

  • Thank you!

At present, the community already hasExplore PHP and Vue Common Direct Out Template Scheme

Not recommended

Php data is used directly in page templates

No matter how the front and back ends are separated, the data of the page still needs to be obtained from the background. There are two ways to get the data: 1. the backstage goes straight out 2.ajax. Personal recommendationajax.

Even full page refresh is obtained through secondary request, isn’t it bad?

On the whole, the advantages outweigh the disadvantages. Of course, this part of the request can be optimized, such as front-end cache data, first-screen data priority request rendering, back-end interface cache, etc.

You can consider server-side rendering favor ofSEO, prioritynodejs, the official support.JavaScriptAndnodejsThe origin is quite deep, cooperate with each other, just like men and women work alone.