current position:Home>[development diary from 22 years to April] Vue problems encountered in actual projects and their solutions
[development diary from 22 years to April] Vue problems encountered in actual projects and their solutions
2022-04-29 17:18:43【Then play music and dance.】
Catalog
1.svg How to change the color of a picture
2. Overall modification elementUI Component style
3. Horizontal vertical center flex The way
4. There is no scroll bar on the background adaptive screen of the login page
6. Use in templates :class Ternary judgment skills
7. Compatibility -360 Browser justify-content: right; invalid
8.css rgba() Use variables in to control transparency
1.svg How to change the color of a picture
svg give an example :
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="20" height="20" viewBox="0 0 20 20"><clipPath id="master_svg_0"><rect x="0" y="0" width="20" height="20" rx="0"/></clipPath><g clip-path="url(#master_svg_0)"><g><path d="M3.3333331525878904,16.666664123535156L3.3333331525878904,11.666664123535156C3.3333331525878904,7.9847641235351565,6.31810015258789,4.999994123535156,10.00000015258789,4.999994123535156C13.681900152587891,4.999994123535156,16.666700152587893,7.9847641235351565,16.666700152587893,11.666664123535156L16.666700152587893,16.666664123535156L17.50000015258789,16.666664123535156L17.50000015258789,18.333364123535155L2.5000001525878908,18.333364123535155L2.5000001525878908,16.666664123535156L3.3333331525878904,16.666664123535156ZM5.000000152587891,16.666664123535156L15.00000015258789,16.666664123535156L15.00000015258789,11.666664123535156C15.00000015258789,8.905244123535155,12.76140015258789,6.666664123535156,10.00000015258789,6.666664123535156C7.238580152587891,6.666664123535156,5.000000152587891,8.905244123535155,5.000000152587891,11.666664123535156L5.000000152587891,16.666664123535156ZM9.16667015258789,1.6666641235351562L10.833330152587891,1.6666641235351562L10.833330152587891,4.166664123535156L9.16667015258789,4.166664123535156L9.16667015258789,1.6666641235351562ZM16.48170015258789,4.006664123535156L17.66000015258789,5.184994123535157L15.89330015258789,6.952494123535156L14.71420015258789,5.774164123535156L16.48170015258789,4.006664123535156M2.3400001525878906,5.184994123535157L3.5183301525878905,4.006664123535156L5.285830152587891,5.7733341235351565L4.10833015258789,6.953334123535156L2.3400001525878906,5.184994123535157ZM5.833330152587891,11.666664123535156C5.833330152587891,9.365474123535156,7.698810152587891,7.499994123535156,10.00000015258789,7.499994123535156L10.00000015258789,9.166664123535156C8.61929015258789,9.166664123535156,7.500000152587891,10.285954123535156,7.500000152587891,11.666664123535156L5.833330152587891,11.666664123535156Z" fill-opacity="1"/></g></g></svg>
Delete... On the label fill, Total deletion 2 individual
Just think of him as an ordinary label
fill="none" fill="#000000"
2. Overall modification elementUI Component style
For example, I want to reduce the size of all input boxes of the project , You can set the style to make the global effect , But it is easy to cause other components to change . The recommended practice is , Add a separate parent class name where we want to change , So you can't choose anywhere else .
3. Horizontal vertical center flex The way
flex Has been compatible with more browsers , Compared with positioning and other ways , It doesn't matter what element you are , All done .
Use flex:
display:flex; justify-content: center;// Horizontal center align-items: center;// Vertical center
4. There is no scroll bar on the background adaptive screen of the login page
min-height: 100%; width: 100%; overflow: hidden; background-image: url("[email protected]/assets//common/bjlogo.png"); // Set the background image background-position: center; // Start rendering from the middle background-size: cover;// Set the picture position to fill the entire screen background-repeat: no-repeat;// Don't spread
Several ways :
1.background-size: 100% 100%; The picture is easy to deform
2.background-size: 100% auto; Better than the first , But as the screen changes, there will be white space
3.background-size: contain; Keep the width height ratio of the picture , It won't deform , But it may lead to blank
4.background-size: cover; A relatively good way , It won't deform , No blank , It may lead to incomplete picture display .
5. Exit function - Universal
be based on elementUI:
logout () { this.$confirm(' Are you sure you want to leave ?', ' Tips ', { confirmButtonText: ' determine ', cancelButtonText: ' Cancel ', type: 'warning', customClass: 'confirm-p'// Be careful : Here is to set your own class name , Then you can modify the style arbitrarily through the class name }).then(async () => { // Clear local information await this.$store.dispatch('user/userLogout') // Go back to the landing page const curPath = encodeURIComponent(this.$route.fullPath) this.$router.push('/login?return_url=' + curPath) }).catch(() => { }) }
6. <template> Use in templates :class Ternary judgment skills
Using ternary to make secondary judgment is easy to lead to code confusion ( Look at the mess ) have access to :class+:style Use a combination of , This makes the code clearer
7. Compatibility -360 Browser justify-content: right; invalid
Only need to right Change it to flex-end that will do
8.css rgba() Use variables in to control transparency
// Use a : Set random colors :style="{backgroundColor:`rgba(${getRandomColor().ran},${getRandomColor().ran2},${getRandomColor().ran3},1`}" // usage 2:js Controls the transparency of colors template in : <el-button type="warning" plain class="btnHover" style=" background: #fff; font-weight: 600; " :style="{ color: `rgba(243, 95, 40, ${alpha}`, border: `1px solid rgba(243, 95, 40, ${alpha}`, }" @click="del2" > Delete </el-button > data Definition : alpha:0.5 // The initial value is given to 0.5 js…… A little
copyright notice
author[Then play music and dance.],Please bring the original link to reprint, thank you.
https://en.qdmana.com/2022/119/202204291527149698.html
The sidebar is recommended
- Function of host parameter in http
- Use nginx proxy node red under centos7 and realize password access
- Centos7 nginx reverse proxy TCP port
- In eclipse, an error is reported when referencing layuijs and CSS
- Front end online teacher Pink
- Learn to use PHP to insert elements at the specified position and key of the array
- Learn how to use HTML and CSS styles to overlay two pictures on another picture to achieve the effect of scanning QR code by wechat
- Learn how to use CSS to vertically center the content in Div
- Learn how to use CSS to circle numbers
- Learn to open and display PDF files in HTML web pages
guess what you like
The PHP array random sorting function shuffle() randomly scrambles the order of array elements
JQuery implements the keyboard enter search function
16 ArcGIS API for JavaScript 4.18 a new development method based on ES modules @ ArcGIS / core
17 ArcGIS API for JavaScript 4.18 draw points, lines and faces with the mouse
18 ArcGIS API for JavaScript 4.18 obtain the length and area after drawing line segments and surface features
Vue environment construction -- scaffold
Build a demo with Vue scaffold
Using vuex in Vue projects
Use Vue router in Vue project
26 [react basics-5] react hook
Random recommended
- 07 Chrome browser captures hover element style
- WebGIS development training (ArcGIS API for JavaScript)
- Solution to the blank page of the project created by create react app after packaging
- 19. Html2canvas implements ArcGIS API for JavaScript 4 X screenshot function
- Introduction to JavaScript API for ArcGIS 13
- Development of ArcGIS API for JavaScript under mainstream front-end framework
- Nginx learning notes
- Less learning notes tutorial
- Vue2 cannot get the value in props in the data of the child component, or it is always the default value (the value of the parent component comes from asynchrony)
- LeetCode 217. Determine whether there are duplicate elements in the array
- I'll write a website collection station myself. Do you think it's ok? [HTML + CSS + JS] Tan Zi
- Front end browser debugging tips
- Application of anti chattering and throttling in JavaScript
- How to create JavaScript custom events
- Several ways of hiding elements in CSS
- node. Js-3 step out the use of a server and express package
- CSS matrix function
- Fastapi series - synchronous and asynchronous mutual conversion processing practice
- How to extend the functionality of Axios without interceptors
- Read pseudo classes and pseudo elements
- About node JS server related concepts
- Access control module (2)
- About virtual lists
- Developing figma plug-in using Vue 3 + vite
- Learn more about the garbage collection engine of chrome V8 JavaScript engine
- Vue3 uses vite instead of webpack
- How to upload applet code through node? Just take a look
- Using H5 video tag in Vue to play local video in pop-up window
- What is the difference between classes in Es5 and ES6?
- [Vue] play with the slot
- [Part 4 of front-end deployment] using docker to build cache and multi-stage construction to optimize single page applications
- Vue2 simple use of vant (based on Vue CLI)
- node. JS server
- React uses concurrent mode. When the rendering phase exceeds the time slice, high priority tasks jump the queue. How will the lanes on the fiber of the previous task be solved
- Vuecli2 multi page, how to remove HTML suffix
- Vue router dynamically modifies routing parameters
- How to use webpack or configure quasar after context isolation is turned on by electron?
- Vue3 how do parent components call child component methods
- Es learning notes (I): http request
- 【Java WEB】AJAX