Questions about building a large SPA

Source: Internet
Author: User
Is Angular. js, Vue. js, or React. js used in the whole site? I want to use SPA and backend PHP to complete the project. What is the feasibility? If SPA is used, how does one deal with Data Interaction? Is ajax used or stateless APIs called to interact with data? How does one deal with cookies... does Angular be used for all websites. js or Vue. js or React. js? I want to use SPA and backend PHP to complete the project. What is the feasibility? If you use SPA, how do you deal with Data Interaction? Do you use ajax or call stateless APIs to interact with data? How do you deal with cookies and sessions.

Reply content:

Is Angular. js, Vue. js, or React. js used in the whole site? I want to use SPA and backend PHP to complete the project. What is the feasibility? If you use SPA, how do you deal with Data Interaction? Do you use ajax or call stateless APIs to interact with data? How do you deal with cookies and sessions.

Try to talk about my thoughts:

  • Does a stateless API mean that the user's identity is not verified? In this case, stateless APIs can be used for non-sensitive information (such as relatively fixed large association drop-down lists.

  • The SPA front-end does not need to directly use cookies (refer to the next one). session allows the backend PHP to process the cookies. The cookies containing necessary information are submitted to the backend in each xhr request.

  • There is no big difference between the PHP end and traditional development. It should be simpler. rendering is no longer needed. Basically, every request ends with a JSON output.

  • If the front-end needs to save some information for the next time you open the page, you can use localStorage.

  • The router of a large SPA front-end should be very important, so you need to take it seriously. Because the user may add a new URL that is not the initial URL to the favorites folder.

  • It may not be suitable for low-configuration devices (such as small-memory Android phones or PCs that are still running XP 10 years ago. However, SPA applications are often more avant-garde and may not face such problems.

Angularjs is no problem in developing single-page applications. Our company uses angularjs + java. Java only provides the data (json) interface (restful ). The $ resource Service of angular. js is installed with ajax and uses delayed objects to solve callback and other problems. Angula. js applications should be layered, which is similar to mvc in the background. The functions of each layer are clear, so that the entire project will not be confused. You can go to a template program and change the template to your own project. Search for the project starting with generator-In npm.

If angular and ajax are used, the seo problem cannot be avoided. If it is a cookie, you can see how to store ngCookie on the official website api

If the site is on a mobile site, you can fully consider SPA

The rare earth nuggets seem to have been developed by Vue on the entire site. You can check it out.

Worktile is the SPA. Let's take a look at the technical architecture secrets of the Worktile team collaboration tool.

In addition, the larger the SPA project, the good file organization structure and automatic configuration must be established in the early stage. I have to mention the seeds of the angular project of F. I .S, which is very good. It is worth looking.

A token is returned for logon.
Then, the user identity operation is required to pass the token
In this way, no cookie or session is required.

The whole site SPA did it when I wrote a small project. It used reactjs and used superagent for interaction with the background. In fact, ajax was used. At that time, I checked a lot of information for identity verification, the last step is to save an identity in the background after logging on, return the token, and save it locally. After each request is sent with the token for verification, a new token is returned, this is actually a big problem, but there are more or less problems with other methods. However, since we plan to use restful, I personally think it is most convenient to directly Use HTTPS.
About front-end separation can look at me this (but the background is java...): http://git.oschina.net/oneayst/springmvc-shiro-react-redux-restful-example/tree/master

By the way, I will post a discussion about restful authentication. For more information, see.
Http://stackoverflow.com/questions/319530/restful-authentication

I personally think that SPA does not mean to be completely stateless .. (I seem to have run the question)

Authentication? Use session as usual. Ajax also carries cookies

There are a lot of spas on the mobile end. In addition, seo problems can be solved by combining the framework with server rendering,

I recently used riotjs to create a spa e-commerce project. PHP writes the rest service, which is provided to front-end pages and Android clients for calling.
Use riotjs to build the entire project, including the Home Page, list, details, shopping cart, order, and login pages.

Angular. js is a framework created for spa, which has some minor seo problems, but it can be solved by other means.
Vue. js is good, but it is good for spa. I think many uc applications use this as the underlying framework, and the mobile end is still good.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.