⭐vue.config.js配置
https://www.jianshu.com/p/b358a91bdf2d
⭐css清除默认样式
1 /** 2 * Eric Meyer's Reset CSS v2.0 (http://meyerweb.com/eric/tools/css/reset/) 3 * http://cssreset.com 4 */ 5 html, body, div, span, applet, object, iframe, 6 h1, h2, h3, h4, h5, h6, p, blockquote, pre, 7 a, abbr, acronym, address, big, cite, code, 8 del, dfn, em, img, ins, kbd, q, s, samp, 9 small, strike, strong, sub, sup, tt, var, 10 b, u, i, center, 11 dl, dt, dd, ol, ul, li, 12 fieldset, form, label, legend, 13 table, caption, tbody, tfoot, thead, tr, th, td, 14 article, aside, canvas, details, embed, 15 figure, figcaption, footer, header, 16 menu, nav, output, ruby, section, summary, 17 time, mark, audio, video, input { 18 margin: 0; 19 padding: 0; 20 border: 0; 21 font-size: 100%; 22 font-weight: normal; 23 vertical-align: baseline; 24 } 25 26 /* HTML5 display-role reset for older browsers */ 27 article, aside, details, figcaption, figure, 28 footer, header, menu, nav, section { 29 display: block; 30 } 31 32 body { 33 line-height: 1; 34 } 35 36 blockquote, q { 37 quotes: none; 38 } 39 40 blockquote:before, blockquote:after, 41 q:before, q:after { 42 content: none; 43 } 44 45 table { 46 border-collapse: collapse; 47 border-spacing: 0; 48 } 49 50 /* custom */ 51 a { 52 color: #7e8c8d; 53 text-decoration: none; 54 -webkit-backface-visibility: hidden; 55 } 56 57 li { 58 list-style: none; 59 } 60 61 ::-webkit-scrollbar { 62 width: 5px; 63 height: 5px; 64 } 65 66 ::-webkit-scrollbar-track-piece { 67 background-color: rgba(0, 0, 0, 0.2); 68 -webkit-border-radius: 6px; 69 } 70 71 ::-webkit-scrollbar-thumb:vertical { 72 height: 5px; 73 background-color: rgba(125, 125, 125, 0.7); 74 -webkit-border-radius: 6px; 75 } 76 77 ::-webkit-scrollbar-thumb:horizontal { 78 width: 5px; 79 background-color: rgba(125, 125, 125, 0.7); 80 -webkit-border-radius: 6px; 81 } 82 83 html, body { 84 width: 100%; 85 } 86 87 body { 88 -webkit-text-size-adjust: none; 89 -webkit-tap-highlight-color: rgba(0, 0, 0, 0); 90 }
⭐修改element-ui样式不可以用scoped
⭐div在屏幕居中
https://zhuanlan.zhihu.com/p/114396520
⭐word-spacing属性调整单词间距,letter-spacing属性调整字之间间距
⭐vue的跳转方式
https://www.cnblogs.com/mouseleo/p/11364333.html
⭐vue修改data里的数据
⭐JS获取各种浏览器窗口可视部分大小(可视部分不包含工具栏、标签栏等)
1 function getViewportSize(w){ 2 w= w || window; 3 //除了IE8以及更早版本外,其它浏览器都能用 4 if(w.innerWidth != null){ return { w:w.innerWidth, h:w.innerHeight } }; 5 //对标准模式下的IE或任何浏览器 6 var d=w.document; 7 if(document.compatMode == "CSS1Compat"){ 8 return { w:d.documentElement.clientWidth, 9 h:d.documentElement.clientHeight } 10 } 11 //对怪异模式下的浏览器 12 return { w:d.body.clientWidth , h:d.body.clientHeight } 13 } 14 let aaa = getViewportSize(); 15 aaa.w是可见宽度 16 aaa.h是可见高度
⭐vue通过data值改变css样式
https://blog.csdn.net/weixin_40829594/article/details/100977722
⭐vue监听浏览器窗口大小变化
1 <template> 2 <section class="p-10"> 3 <h1> {{ screenWidth }} × {{ screenHeight }} </h1> 4 </section> 5 </template> 6 <script> 7 export default { 8 data() { 9 return { 10 screenWidth: '', 11 screenHeight: '' 12 }; 13 }, 14 mounted() { 15 this.screenWidth = document.body.clientWidth; 16 this.screenHeight = document.body.clientHeight; 17 window.onresize = () => { 18 return (() => { 19 this.screenWidth = document.body.clientWidth; 20 this.screenHeight = document.body.clientHeight; 21 })(); 22 }; 23 } 24 } 25 </script> 26 27 <style lang="scss"> 28 </style>
⭐做vue整页面轮播图时适配方法
1 <template> 2 <div class="projectProgress"> 3 <el-carousel 4 trigger="click" 5 :height="height + 'px'" 6 :interval="30000" 7 indicator-position="none" 8 > 9 <el-carousel-item> 10 <img 11 :class="[isWidth ? 'isWidth' : 'isHeight']" 12 src="http://zs-tek.com/static/img/projectProgress/1%E9%A1%B9%E7%9B%AE%E7%9C%8B%E6%9D%BF.png" 13 /> 14 </el-carousel-item> 15 <el-carousel-item> 16 <img 17 :class="[isWidth ? 'isWidth' : 'isHeight']" 18 src="http://zs-tek.com/static/img/projectProgress/2%E9%A1%B9%E7%9B%AE%E5%BD%92%E6%A1%A3.png" 19 /> 20 </el-carousel-item> 21 <el-carousel-item> 22 <img 23 :class="[isWidth ? 'isWidth' : 'isHeight']" 24 src="http://zs-tek.com/static/img/projectProgress/3%E4%BA%BA%E6%89%8D%E5%88%86%E5%B8%83.png" 25 /> 26 </el-carousel-item> 27 <el-carousel-item> 28 <img 29 :class="[isWidth ? 'isWidth' : 'isHeight']" 30 src="http://zs-tek.com/static/img/projectProgress/4%E4%B8%93%E5%88%A9%E6%8A%80%E6%9C%AF.png" 31 /> 32 </el-carousel-item> 33 </el-carousel> 34 </div> 35 </template> 36 37 <script> 38 export default { 39 data() { 40 return { 41 height: 0, 42 0, 43 isWidth: true 44 }; 45 }, 46 methods: { 47 calculationHeight: function() { 48 return window.document.documentElement.clientHeight; 49 }, 50 calculationWidth: function() { 51 return window.document.documentElement.clientWidth; 52 } 53 }, 54 created() { 55 this.height = this.calculationHeight(); 56 this.width = this.calculationWidth(); 57 // console.log(this.calculationHeight(), this.calculationWidth()); 58 if (this.width / this.height > 16 / 9) { 59 this.isWidth = false; 60 } else { 61 this.isWidth = true; 62 } 63 }, 64 mounted() { 65 window.onresize = () => { 66 return (() => { 67 this.height = this.calculationHeight(); 68 this.width = this.calculationWidth(); 69 if (this.width / this.height > 16 / 9) { 70 this.isWidth = false; 71 } else { 72 this.isWidth = true; 73 } 74 })(); 75 }; 76 } 77 }; 78 </script> 79 80 <style> 81 .isWidth { 82 max- 100vw; 83 } 84 .isHeight { 85 max-height: 100vh; 86 } 87 .projectProgress .el-carousel__item h3 { 88 color: #475669; 89 font-size: 14px; 90 opacity: 0.75; 91 line-height: 150px; 92 margin: 0; 93 } 94 .projectProgress .el-carousel__item:nth-child(n) { 95 background-color: #fff !important; 96 } 97 .projectProgress .el-carousel__button { 98 background-color: #000 !important; 99 } 100 .projectProgress .el-carousel__arrow { 101 background-color: rgba(0, 0, 0, 0.211) !important; 102 color: #fff6 !important; 103 60px; 104 height: 60px; 105 font-size: 40px; 106 } 107 .el-carousel__item { 108 overflow: visible; 109 } 110 </style>