In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces the knowledge of "how to use Vue to build a personal blog". In the operation of actual cases, many people will encounter such a dilemma. Next, let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Recently, on a whim, I have been developing a personal blog website, and I can take this opportunity to produce a series of articles about the design of the front-end interface, the implementation of the back-end business logic and the interaction between the front and back ends. I use Vue.js + Node.js + mysql for the specific architecture. The front-end interface design uses element-ui and mavon-editor, while the back-end still uses the express framework. The home page effect and the article publishing interface effect are shown in the figure:
Next, we begin to build the front and back end environment. First of all, I just skip the installation of Node.js and mysql, download and install next and then install it successfully. We first install vue-cli scaffolding globally with the following command:
Npm install vue-cli-g
Then use vue-cli to build a vue2.0 project, and command:
Vue init webpack vue_demo
For the time being, I only chose vue-router for the integrated function. I have not chosen to install eslint or unit tests for the time being. Then you can start the vue project with the command:
Npm run dev
At this point, our front-end vue environment is temporarily over. Next, let's build the express project. First install the express generator globally, and the command is:
Npm install express-generator-g
Then use express-generator to quickly build an express project with the following command:
Express article_demo
Then follow the prompts to enter the project installation dependency, which can start the project if the installation is successful.
The express has been successfully built here, but we need to configure the express properly: connect to the database and a public method to initiate the request. First, create a config.js file in the project root directory to hold the database configuration information and common parameters.
Then create a db folder in the root directory of the project, and create an encapsulation of the initialization, addition, deletion, modification and query method of mysql.js for mysql database connections under the db folder:
Create a util folder under the root of the project to hold public methods. Create a postHelper.js file under util, and the user encapsulates the request request. When we call a third-party API, such as Wechat Select articles, we need to initiate a request:
Then create a common.js file under util to store global public methods, such as registration password encryption, receiving frontend parameters, and so on:
Create a bootloader.js under util to encapsulate the global log method and the correct and error return format of the API return parameters:
Open the package.json file in the root directory and add the configuration of apidoc. Apidoc is used to automatically generate interface documents based on interface comments:
Finally, open the app.js file and set up to allow cross-domain requests. Currently, in the local test, I set to allow all domain names to be accessed across domains:
"how to use Vue to build a personal blog" content is introduced here, thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.