動態

詳情 返回 返回

Vue適配PC+大屏,手機+ipad適配 - 動態 詳情

PC+大屏適配

可適配 1400px以上的屏幕

image.png

查看演示
項目地址

設置設計稿-轉換rem

我們的設計稿是3840px寬度,所以widthOfDesignLayout設置3840

module.exports = {
    plugins: {
        autoprefixer: {},
        "@njleonzhang/postcss-px-to-rem": {
            unitToConvert: "px",
            widthOfDesignLayout: 3840, // 設計稿的寬度 ,就是設計的UI寬度
            unitPrecision: 3, // 十進制的單位.
            selectorBlackList: [".ignore", ".hairlines"], // 過濾那些不用轉換的class
            minPixelValue: 1, // 設置要替換的最小像素值.
            mediaQuery: false, // 允許在媒體查詢中轉換px
        },
    },
};

設置根節點字體

在main.js下,保證在屏幕縮放的過程中也是16:9的比列,查看該插件

const dashboardFlexible = require('lib-flexible-for-dashboard');
dashboardFlexible.init(16/9)

開發

image.png

設計給出多少就是多少

button {
    width: 465px;
    height: 112px;
}

手機+ipad適配

可適配手機+ipad

演示地址

項目地址

轉換Rem

css: {
        loaderOptions: {
            postcss: {
                plugins: [
                    require("postcss-pxtorem")({
                        rootValue: 75, // 換算的基數 1rem = 75px 這個是根據750px設計稿來的,如果是620 的就寫 62
                        // 忽略轉換正則匹配項。插件會轉化所有的樣式的px。比如引入了三方UI,也會被轉化。目前我使用selectorBlackList字段,來過濾
                        //如果個別地方不想轉化px。可以簡單的使用大寫的 PX 或 Px 。
                        selectorBlackList: ['van-'],
                        propList: ["*"], // 需要做轉化處理的屬性,如`hight`、`width`、`margin`等,`*`表示全部
                    }),
                ],
            },
        },
    },

設置根節點字體

import 'lib-flexible' 

開發

設計給的是750px的設計稿 是多少填多少,比如這個框的高度是96px就直接寫96px

image.png

設計稿是多少就是多少

height: 72px;
background: rgba(238, 238, 238, 0.5);
border-radius: 36px;

其他解決方案

大屏數據可視化——屏幕適配方案(多分辨率下

user avatar cyzf 頭像 steven_code 頭像 front_yue 頭像 jingdongkeji 頭像 linx 頭像 shuirong1997 頭像 febobo 頭像 yqyx36 頭像 zxl20070701 頭像 romanticcrystal 頭像 lin494910940 頭像 joe235 頭像
點贊 68 用戶, 點贊了這篇動態!
點贊

Add a new 評論

Some HTML is okay.