current position:Home>[vue2-sgg VII] Vue export and deploy to nginx --- UI component library (element UI...)
[vue2-sgg VII] Vue export and deploy to nginx --- UI component library (element UI...)
2022-04-29 07:23:46【xbd_ zc】
7、 ... and ,Vue Deploy to Nginx
0, install nginx
Download from the official website nginx: download
Windows download Windows Version decompression
centos7 install
# Download installation package
wget http://nginx.org/download/nginx-1.20.2.tar.gz
# Dependencies required for installation
yum -y install pcre pcre-devel zlib zlib-devel openssl openssl-devel
# decompression
tar -zxvf nginx-1.20.2.tar.gz
# Get into nginx Catalog
cd nginx-1.20.2
# precompile
#--prefix Is to specify the installation directory
./configure --prefix=/opt/nginx
# compile
make
# install
make install
# function nginx
cd /opt/nginx/sbin/
./nginx
# Check the process
ps -ef|grep nginx
root 115792 1 0 14:40 ? 00:00:00 nginx: master process ./nginx
nobody 115793 115792 0 14:40 ? 00:00:00 nginx: worker process
root 116079 15539 0 14:40 pts/2 00:00:00 grep --color=auto nginx
# Unable to access closed firewall or open port
systemctl stop firewalld.service # Temporary firewall
systemctl disable firewalld.service # Permanently shut down firewall
# to open up 80 port
firewall-cmd --zone=public --add-port=80/tcp --permanent # to open up 80 port
firewall-cmd --zone=public --remove-port=80/tcp --permanent # close 80 port
firewall-cmd --reload # Configuration takes effect immediately
firewall-cmd --zone=public --list-ports # View open ports of firewall
Common commands
# start-up
/opt/nginx/sbin/nginx
# Start the configuration file in a specific directory
nginx -c / Specific directory /nginx.conf
# Reload configuration
/opt/nginx/sbin/nginx -s reload
# stop it
/opt/nginx/sbin/nginx -s stop
# Check if the configuration file is correct
/opt/nginx/sbin/nginx -t
# Check that the configuration file for a specific directory is correct
nginx -t -c / Specific directory /nginx.conf
# Out of Service
/opt/nginx/sbin/nginx -s quit
To configure nginx service ( Boot from boot )
vim /etc/systemd/system/nginx.service # establish service file
nginx.service
[Unit]
Description=The Nginx HTTP Server
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/opt/nginx/logs/nginx.pid # Modify the path to the path corresponding to your own system
ExecStart=/opt/nginx/sbin/nginx
ExecReload=/opt/nginx/sbin/nginx -s reload
ExecStop=/opt/nginx/sbin/nginx -s stop
PrivateTmp=true
[Install]
WantedBy=multi-user.target
Boot from boot
systemctl daemon-reload
systemctl enable nginx # Boot from boot
systemctl disable nginx.service # Turn off and start automatically
systemctl start nginx.service # Turn on
systemctl stop nginx.service # close
systemctl reload nginx.service # Reload configuration
systemctl status nginx.service # Check the status
1, function build command
vue-cli-service build
2, Generate resource directory dist, Copied to the nginx in
Download from the official website nginx: download
# stop it
nginx -s quit
# restart
nginx -s reload
hold dist Put the resources in the directory into HTML Under the table of contents
3, Access test
4,history New newspaper in mode 404
- Use the path as a resource to find , Can't find
modify nginx.conf
server–>location Add
try_files $uri $uri/ @router;
server {
listen 8088;
server_name xxx;
access_log logs/access.log;
error_log logs/error.log;
location / {
# root directory
root E:\static\disthistory;
#history add to , hash Don't add
try_files $uri $uri/ @router;
# Point to 17 Yes @router
index index.html;
}
# Corresponding 11 Yes @router, The main reason is that the route resource is not a real path , So we can't find the specific documents
# Therefore need rewrite To index.html in , Then it's handed over to the router to process the request resource
location @router {
rewrite ^.*$ /index.html last;
}
}
8、 ... and ,UI Component library (Element UI)
Mobile terminal is often used UI Component library
- Vant https://youzan.github.io/vant
- Cube Ul https://didi.github.io/cube-ui-
- Mint UI http://mint-ui.github.io
PC Common end UI Component library
- Element UI https://element.eleme.cn
- IView Ul https://www.iviewui.com-
Element UI
npm install
Recommended npm Mode of installation , It can be better with webpack Packing tools are used with .
npm i element-ui -S
introduce
// introduce ElementUI Component library
import ElementUI from 'element-ui';
// introduce ElementUI All styles
import 'element-ui/lib/theme-chalk/index.css';
// application ElementUI
Vue.use(ElementUI);
Introduce on demand
With the help of babel-plugin-component, We can just introduce the components we need , In order to reduce the volume of the project .
First , install babel-plugin-component:
npm install babel-plugin-component -D
then , take .babelrc
It is amended as follows :
The new scaffold is called babel.config.js
module.exports = {
presets: [
'@vue/cli-plugin-babel/preset',
//"presets": [["es2015", { "modules": false }]],es2015 Report errors
["@babel/preset-env", {
"modules": false }]
],
"plugins": [
[
"component",
{
"libraryName": "element-ui",
"styleLibraryName": "theme-chalk"
}
]
]
}
Next , If you only want to introduce some components , such as Button and Select, So you need to main.js Write the following in :
import Vue from 'vue';
import {
Button, Select } from 'element-ui';
import App from './App.vue';
Vue.component(Button.name, Button);
Vue.component(Select.name, Select);
/* Or write as * Vue.use(Button) * Vue.use(Select) */
new Vue({
el: '#app',
render: h => h(App)
});
Operation error reporting
If appear Error: Cannot find module 'xxx'
Just install npm i xxx
install babel-plugin-component
npm i babel-plugin-component
install babel-preset-es2015
npm i babel-preset-es2015
es2015 The problem of
modify babel.config.js
Of es2015
by @babel/preset-env
module.exports = {
presets: [
'@vue/cli-plugin-babel/preset',
["@babel/preset-env", {
"modules": false }]
],
"plugins": [
[
"component",
{
"libraryName": "element-ui",
"styleLibraryName": "theme-chalk"
}
]
]
}
Cannot find module '@babel-preset-env/babel-preset' solve : Switch to ['@babel/env', { modules: false }]
copyright notice
author[xbd_ zc],Please bring the original link to reprint, thank you.
https://en.qdmana.com/2022/119/202204290422108080.html
The sidebar is recommended
- How to realize Ethernet wireless communication between 200smartplc?
- Still working on nginx configuration? Try this visual configuration tool. It's really powerful!
- Simple sorting of JavaScript deep copy and shallow copy
- React realizes the communication of brother components by means of message subscription and publication
- React limits props
- Java lesson 30
- Java lesson 29 136 The number 1189 appears only once Maximum number of balloons
- Simple sorting of JavaScript deep copy and shallow copy
- "Geely" new SUV is equipped with frameless doors, and the interior is more beautiful than Mercedes Benz. Can 19 universal accept it?
- Configuration of using less in react project
guess what you like
Expression used in react render
React configuration agent
JQuery sends a post request (a method of connecting PHP variables to strings)
Solve the problem that Django cannot access the local server( http://127.0.0.1:8000/ )Or the problem that the command line execution (Python 3 manage.py runserver 0.0.0.0:8000) does not respond
Summary of the writing method of react router V6
Bipeng ditch, punch in and net red, open-air boundless swimming pool, Ramada hot spring, encounter the beauty of the four seasons
JavaScript gets and modifies elements. What's wrong with not extracting the classlist attribute
Mixed mixin of Vue
Vue + element implements table filtering
Vue router2. 0
Random recommended
- Which one charges less for opening a securities account and how to open the account
- Spring MVC notes 02 domain object sharing data, view, restful, httpmessageconverter, file upload and download
- Httpclient setting timeout
- Command line / Python uses pdf2htmlex to convert PDF to HTML
- [front end three swordsmen III] analysis of JavaScript scalpel Part II
- How to choose the front-end learning path
- Finite element parametric element, calculation, theoretical problems
- Handwritten CSS modules to understand its principle
- Front end browser debugging tips
- Performance problem analysis guide for enterprise JavaScript applications running in production systems
- CSS aspect-ratio All In One
- Actual combat of vue3 project --- Zhihu daily --- details page
- Actual combat of vue3 project --- Zhihu daily --- home page function
- Great Wall Motors is falling endlessly! The boss has lost 150 billion yuan in half a year, and the performance of the new energy sector has improved
- Nginx tips batch shutdown process
- Openresty introduces nginx_ upstream_ check_ Module module
- Nginx multiple servers_ How does name match
- Why does the front end still prompt cannot post, and the error reported by the back end still prompt null pointer?
- HTML Li set margin: 50%, but the width of the outermost div is the standard
- Are there any specific steps to create a prototype, such as JavaScript?
- How does HTML5 display the value obtained from the database in the specified area
- Problems related to nginx rewriting interface
- What happens when you open a CSS file in eclipse without responding
- React download local template can be downloaded locally, but the deployment online download is blank
- @Babel / traverse official example running error: typeerror: traverse is not a function
- The click event of jQuery has no effect
- How to learn from non professional background?
- Usage of API documented as @since 1.8+ less... (Ctrl+F1) Inspection info: This inspection finds all
- Configuration Vue of webpack
- Introduction to nginx (learning notes)
- Is the financial management class of qiniu school true? Can you learn how to manage money in free lessons
- How does Java randomly get elements from a list
- Use of Vue on in Vue
- Use of Vue router
- Vue basic syntax
- Use of webpack
- Vue diff algorithm
- CSS -- Text gradient from top to bottom
- Routing: Vue router
- Leetcode 658. Find K closest elements