Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Sample analysis of beego+vue.js separate development and combined release and simple deployment

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article shows you beego+vue.js separate development and release and simple deployment of the sample analysis, the content is concise and easy to understand, absolutely can make your eyes bright, through the detailed introduction of this article hope you can get something.

As we all know, the simple deployment of things developed by golang is its big selling point. For general applications, the executable files generated can be run directly on the server without any environment. Of course, large applications such as mysql,nginx are needed.

But when vue.js appeared, the front end was almost dominated by it (vue.js), because with vue.js, I couldn't go back. I couldn't go back to beego's view to write tpl or html pages. I was hurt, and I couldn't help it. Vue.js is so convenient. The so-called two-way binding, this is the concept of god horse, Baidu, I don't know.

It was silly to deploy the front end of vue.js development completely independently on the cloud (using nginx as the front-end static server, configuring a bunch, which is totally unnecessary). In fact, you can put the things packaged by vue.js under the view folder of beego and under the static folder.

My own understanding:

Be sure to use an independent front end when developing, that is, the vue.js front end project must be an independent, independent service, not in the view in beego as a tpl page. Although the tpl in beego view seems to achieve a lot of functions by quoting vue, element, axios, etc., it is very abusive, so don't try again unless you have to. One of the reasons, of course, is that there are no tutorials and ready-made cases like this, and there are a lot of things that need to be tested. Such as axios, routing and so on.

When setting up the environment of nodejs and vue independently, use Taobao image, initialize a project, and then copy all kinds of network code, such as streamline, very smooth.

After developing the vue.js project independently, it can be packaged and put into the beego.

It's easy to deploy:

1. In vue.js, cnpm run build packages to get the dist folder, which contains index.html and static folders.

two。 Put the index.html directly under the view folder of beego, then add a route to the route and controllers of beego and point to this index.html to access it.

3. Go to the static folder under the dist folder, copy all the files and folders inside, and paste the same folder in the static folder that comes to beego, then merge the folder.

4. Enter the route and you can access it.

The principle is actually to make use of the static service function of the go language.

The above is a sample analysis of beego+vue.js separate development and combined release and simple deployment. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report