VueはVwを使ってモバイル端末を作るのに適しています.
vue-cliを使ってプロジェクトディレクトリを構築します.
postcs-inmport:ローカルファイル、ノードまたはnode-modulesモジュールを導入してくれます.
postcss-aspect-ratio-mini:主に元素の容器のアスペクト比を処理するために用います.
postcss-px-to-viewport:を使って
postcs-write-svg:処理移動端
postcss-cssnext:将来のcss拡張機能を使用できます.
postcss-viewport units:主にCSSの属性に追加します.
cssnano:主にCSSコードを圧縮して整理するのに使います.
cssnano-presete-advanced:cssnanoとしての高級最適化(インストールしないとエラーが発生する可能性があります)
プロジェクトとディレクトリでpostcss.co.fig.jsファイルを作成してコードを導入してください.
エラーが発生した場合は、package.jsonでこのコードを削除し、npm run serveを再確認してください.
vue create
依存パッケージをダウンロードnpm i postcss-url postcss-import postcss-aspect-ratio-mini postcss-px-to-viewport postcss-write-svg postcss-cssnext postcss-viewport-units cssnano cssnano-preset-advanced -S
postcss-url:cssの背景図url参照を解析するプラグインpostcs-inmport:ローカルファイル、ノードまたはnode-modulesモジュールを導入してくれます.
postcss-aspect-ratio-mini:主に元素の容器のアスペクト比を処理するために用います.
postcss-px-to-viewport:を使って
px
単位で変換 vw、
vh、
vmin
または vmax
のようなウィンドウズ単位、コアプラグインpostcs-write-svg:処理移動端
1px
のソリューションは、border-inmageまたはbackground-mageを使用する.postcss-cssnext:将来のcss拡張機能を使用できます.
postcss-viewport units:主にCSSの属性に追加します.
content
の属性、組み合わせ viewport-units-buggyfill
ライブラリの交付 vw、
vh
、vmin
、および vmax
は、適切な動作をする.cssnano:主にCSSコードを圧縮して整理するのに使います.
cssnano-presete-advanced:cssnanoとしての高級最適化(インストールしないとエラーが発生する可能性があります)
プロジェクトとディレクトリでpostcss.co.fig.jsファイルを作成してコードを導入してください.
module.exports = {
plugins: {
"postcss-import": {},
"postcss-url": {},
"postcss-aspect-ratio-mini": {},
"postcss-write-svg": {
utf8: false
},
"postcss-cssnext": {},
"postcss-px-to-viewport": {
viewportWidth: 750, // (Number) The width of the viewport.
viewportHeight: 1334, // (Number) The height of the viewport.
unitPrecision: 3, // (Number) The decimal numbers to allow the REM units to grow to.
viewportUnit: "vw", // (String) Expected units.
selectorBlackList: [".ignore", ".hairlines"], // (Array) The selectors to ignore and leave as px.
minPixelValue: 1, // (Number) Set the minimum pixel value to replace.
mediaQuery: false // (Boolean) Allow px to be converted in media queries.
},
"postcss-viewport-units": {},
cssnano: {
preset: "advanced",
autoprefixer: false,
"postcss-zindex": false
}
}
};
npm run serveを実行します エラーが発生した場合は、package.jsonでこのコードを削除し、npm run serveを再確認してください.
"postcss": {
"plugins": {
"autoprefixer": {}
}
},
注意:Viewport Unity Bugggyfill contentを設定すると副作用があります.例えば、[img]タブの設定がcontentブラウザに画像が表示されないので、[img]全体のスタイルを追加することができます.img{
content:normal !important;
}