新建一个Vue项目

hell,大家早上好、中午好、晚上好、欢迎收看本次文章,我是声音甜美的鸡排妹。今天是周五,今天工作安排些开发移动端,那我漂亮且性感鸡排妹就搭建起来了,过程特别简单。但我想分享大家搭建Vue项目。学校鸡排妹的搭建项目经验。

新建一个Vue项目


新建一个vue项目:

npm install -g vue-cli


vue init webpack vw-layout [vue init webpack (项目名称)]


npm i postcss-aspect-ratio-mini postcss-px-to-viewport postcss-write-svg postcss-cssnext postcss-viewport-units cssnano --S


在.postcssrc.js文件对新安装的PostCSS插件进行配置:

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.

},

"cssnano": {

preset: "advanced",

autoprefixer: false,

"postcss-zindex": false

}

}

}


npm i cssnano-preset-advanced --save-dev


npm install vuex --save

npm install axios --save

npm install [email protected] --save


index.html加个meta标签


npm run dev


config/index.js文件中,host的值改为:”0.0.0.0”

src/router/index.js文件中,Router的配置加上mode: 'history'


"postcss-px-to-viewport": {

viewportWidth: 750, // 视窗的宽度,对应的是我们设计稿的宽度,一般是750

viewportHeight: 1334, // 视窗的高度,根据750设备的宽度来指定,一般指定1334,也可以不配置

unitPrecision: 3, // 指定`px`转换为视窗单位值的小数位数(很多时候无法整除)

viewportUnit: 'vw', // 指定需要转换成的视窗单位,建议使用vw

selectorBlackList: ['.ignore', '.hairlines'], // 指定不转换为视窗单位的类,可以自定义,可以无限添加,建议定义一至两个通用的类名

minPixelValue: 1, // 小于或等于`1px`不转换为视窗单位,你也可以设置为你想要的值

mediaQuery: false // 允许在媒体查询中转换`px`

}


分享到:


相關文章: