rem
This commit is contained in:
		
							parent
							
								
									de899aebc8
								
							
						
					
					
						commit
						c81668f397
					
				@ -11,6 +11,7 @@
 | 
				
			|||||||
    "ant-design-vue": "^2.0.0-beta.9",
 | 
					    "ant-design-vue": "^2.0.0-beta.9",
 | 
				
			||||||
    "axios": "^0.20.0",
 | 
					    "axios": "^0.20.0",
 | 
				
			||||||
    "core-js": "^3.6.5",
 | 
					    "core-js": "^3.6.5",
 | 
				
			||||||
 | 
					    "postcss-pxtorem": "^5.1.1",
 | 
				
			||||||
    "vue": "^3.0.0-0",
 | 
					    "vue": "^3.0.0-0",
 | 
				
			||||||
    "vue-router": "^4.0.0-0",
 | 
					    "vue-router": "^4.0.0-0",
 | 
				
			||||||
    "vuex": "^4.0.0-0"
 | 
					    "vuex": "^4.0.0-0"
 | 
				
			||||||
 | 
				
			|||||||
@ -6,6 +6,60 @@
 | 
				
			|||||||
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
 | 
					    <meta name="viewport" content="width=device-width,initial-scale=1.0">
 | 
				
			||||||
    <link rel="icon" href="<%= BASE_URL %>favicon.ico">
 | 
					    <link rel="icon" href="<%= BASE_URL %>favicon.ico">
 | 
				
			||||||
    <title><%= htmlWebpackPlugin.options.title %></title>
 | 
					    <title><%= htmlWebpackPlugin.options.title %></title>
 | 
				
			||||||
 | 
					    <script>
 | 
				
			||||||
 | 
					       //designWidth:设计稿的实际宽度值,需要根据实际设置
 | 
				
			||||||
 | 
					      //maxWidth:制作稿的最大宽度值,需要根据实际设置
 | 
				
			||||||
 | 
					      //这段js的最后面有两个参数记得要设置,一个为设计稿实际宽度,一个为制作稿最大宽度,例如设计稿为750,最大宽度为750,则为(750,750)
 | 
				
			||||||
 | 
					      (function (designWidth, maxWidth) {
 | 
				
			||||||
 | 
					        var doc = document,
 | 
				
			||||||
 | 
					          win = window,
 | 
				
			||||||
 | 
					          docEl = doc.documentElement,
 | 
				
			||||||
 | 
					          remStyle = document.createElement("style"),
 | 
				
			||||||
 | 
					          tid;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        function refreshRem() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					          var width = docEl.getBoundingClientRect().width;
 | 
				
			||||||
 | 
					          // maxWidth = maxWidth || 540; //不需要判断最大宽度
 | 
				
			||||||
 | 
					          // width > maxWidth && (width = maxWidth);
 | 
				
			||||||
 | 
					          var rem = width * 100 / designWidth;
 | 
				
			||||||
 | 
					        console.log(rem)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					          remStyle.innerHTML = 'html{font-size:' + rem + 'px;}';
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (docEl.firstElementChild) {
 | 
				
			||||||
 | 
					          docEl.firstElementChild.appendChild(remStyle);
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					          var wrap = doc.createElement("div");
 | 
				
			||||||
 | 
					          wrap.appendChild(remStyle);
 | 
				
			||||||
 | 
					          doc.write(wrap.innerHTML);
 | 
				
			||||||
 | 
					          wrap = null;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        //要等 wiewport 设置好后才能执行 refreshRem,不然 refreshRem 会执行2次;
 | 
				
			||||||
 | 
					        refreshRem();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        win.addEventListener("resize", function () {
 | 
				
			||||||
 | 
					          clearTimeout(tid); //防止执行两次
 | 
				
			||||||
 | 
					          tid = setTimeout(refreshRem, 300);
 | 
				
			||||||
 | 
					        }, false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        win.addEventListener("pageshow", function (e) {
 | 
				
			||||||
 | 
					          if (e.persisted) { // 浏览器后退的时候重新计算
 | 
				
			||||||
 | 
					            clearTimeout(tid);
 | 
				
			||||||
 | 
					            tid = setTimeout(refreshRem, 300);
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					        }, false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (doc.readyState === "complete") {
 | 
				
			||||||
 | 
					          doc.body.style.fontSize = "16px";
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					          doc.addEventListener("DOMContentLoaded", function (e) {
 | 
				
			||||||
 | 
					            doc.body.style.fontSize = "16px";
 | 
				
			||||||
 | 
					          }, false);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					      })(1366, 1024);
 | 
				
			||||||
 | 
					    </script>
 | 
				
			||||||
  </head>
 | 
					  </head>
 | 
				
			||||||
  <body>
 | 
					  <body>
 | 
				
			||||||
    <noscript>
 | 
					    <noscript>
 | 
				
			||||||
 | 
				
			|||||||
@ -20,6 +20,7 @@
 | 
				
			|||||||
                            style="width: 171px"
 | 
					                            style="width: 171px"
 | 
				
			||||||
                            size="small"
 | 
					                            size="small"
 | 
				
			||||||
                            ref="select"
 | 
					                            ref="select"
 | 
				
			||||||
 | 
					                            :getPopupContainer="triggerNode => triggerNode.parentNode"
 | 
				
			||||||
                        >
 | 
					                        >
 | 
				
			||||||
                            <a-select-option v-for="(item, index) in ['美国', '英国']" :key="index" :value="item">
 | 
					                            <a-select-option v-for="(item, index) in ['美国', '英国']" :key="index" :value="item">
 | 
				
			||||||
                                {{ item }}
 | 
					                                {{ item }}
 | 
				
			||||||
@ -267,6 +268,7 @@ export default defineComponent({
 | 
				
			|||||||
    width: 100%;
 | 
					    width: 100%;
 | 
				
			||||||
    background-color: #ffffff;
 | 
					    background-color: #ffffff;
 | 
				
			||||||
    padding: 46px;
 | 
					    padding: 46px;
 | 
				
			||||||
 | 
					    position: relative;
 | 
				
			||||||
    .update-btn {
 | 
					    .update-btn {
 | 
				
			||||||
        font-size: 11px;
 | 
					        font-size: 11px;
 | 
				
			||||||
        color: #08AE98;
 | 
					        color: #08AE98;
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										0
									
								
								static/js/common.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								static/js/common.ts
									
									
									
									
									
										Normal file
									
								
							
							
								
								
									
										22
									
								
								vue.config.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								vue.config.js
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,22 @@
 | 
				
			|||||||
 | 
					module.exports = {
 | 
				
			||||||
 | 
					    css: {
 | 
				
			||||||
 | 
					      loaderOptions: {
 | 
				
			||||||
 | 
					        postcss: {
 | 
				
			||||||
 | 
					          plugins: [
 | 
				
			||||||
 | 
					            require('postcss-pxtorem')({ // 把px单位换算成rem单位
 | 
				
			||||||
 | 
					              rootValue: 100, // 换算的基数(设计图750的根字体为32)
 | 
				
			||||||
 | 
					              selectorBlackList: ['weui', 'mu'], // 忽略转换正则匹配项
 | 
				
			||||||
 | 
					              propList: ['*']
 | 
				
			||||||
 | 
					            })
 | 
				
			||||||
 | 
					          ]
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    configureWebpack: config => {
 | 
				
			||||||
 | 
					      if (process.env.NODE_ENV === 'production') {
 | 
				
			||||||
 | 
					        // 为生产环境修改配置...
 | 
				
			||||||
 | 
					      } else {
 | 
				
			||||||
 | 
					        // 为开发环境修改配置...
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
@ -7235,6 +7235,13 @@ postcss-ordered-values@^4.1.2:
 | 
				
			|||||||
    postcss "^7.0.0"
 | 
					    postcss "^7.0.0"
 | 
				
			||||||
    postcss-value-parser "^3.0.0"
 | 
					    postcss-value-parser "^3.0.0"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					postcss-pxtorem@^5.1.1:
 | 
				
			||||||
 | 
					  version "5.1.1"
 | 
				
			||||||
 | 
					  resolved "https://registry.npm.taobao.org/postcss-pxtorem/download/postcss-pxtorem-5.1.1.tgz#198a68c10f9ad2d42370ef66299d7b3168f8cffa"
 | 
				
			||||||
 | 
					  integrity sha1-GYpowQ+a0tQjcO9mKZ17MWj4z/o=
 | 
				
			||||||
 | 
					  dependencies:
 | 
				
			||||||
 | 
					    postcss "^7.0.27"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
postcss-reduce-initial@^4.0.3:
 | 
					postcss-reduce-initial@^4.0.3:
 | 
				
			||||||
  version "4.0.3"
 | 
					  version "4.0.3"
 | 
				
			||||||
  resolved "https://registry.npmjs.org/postcss-reduce-initial/-/postcss-reduce-initial-4.0.3.tgz#7fd42ebea5e9c814609639e2c2e84ae270ba48df"
 | 
					  resolved "https://registry.npmjs.org/postcss-reduce-initial/-/postcss-reduce-initial-4.0.3.tgz#7fd42ebea5e9c814609639e2c2e84ae270ba48df"
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user