Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - How to realize front-end separation in nginx+vue.js
How to realize front-end separation in nginx+vue.js
This paper mainly introduces the sample code of nginx+vue.js to realize front-end separation, and now shares it with you for your reference.

1.nginx is a high-performance HTTP and reverse proxy server, which is often used in distributed server management.

It is usually used for load balancing (by calling multiple servers to achieve this goal)

Static resource output is faster, and it can be output after gzip compression (which is also an important reason why this paper uses it for static resource access).

It is suitable for solving cross-domain problems and reverse proxy (because no one wants to see access to other domain names under this domain name, cross-domain will lead to csrf attacks, which is the second reason for using it in this paper)

It takes up less memory and starts every second, which can quickly switch nodes and prevent downtime.

2.es6 is the sixth version of ECMAScript. If you want to learn the js framework such as vue.js well, you must learn the language. The recommended study address is as follows:. vuejs.org/v2/guide/forms.html).

The following four points refer to official website api and will not be introduced.

4. How to achieve deep response (how to modify the first page after it is initialized)?

5. Customize the component application and use Render to create the Html structure.

6. Use of routing

7. Common modifiers

6. Examples of actual combat

1.nginx Configure Static Resources

Server {

Listen to 4000;

Server name www.test.com;

Character set utf-8;

Index/ static/index.html; //Configure Home Page

//Regular expressions can be used here to intercept requests for dynamic data, thus solving cross-domain problems.

location = /sellingJson.html {

proxy _ pass:4000/selling JSON . html ')

. Then (function (data) (

//Define a vue object to facilitate template rendering.

v =Object.assign(v,new Vue({

Al:'. Char_contain',//Binding event name

Data: {

Carplandlist: data.data.carplandlist,//data stream

}

}));

})

. Catch (function (error) (

console . log(err);

});

}); The above is what I arranged for you, and I hope it will help you in the future.

Related articles:

How to achieve the effect of intermittent circular scrolling of words through JS

Explain refs (detailed tutorial) in React in detail.

Using tween.js to realize the animation algorithm of slow motion tweening.