vite 3.0 版本需要 node.js 16.0 以上
winpty npm.cmd init vite@latest // windows系统需要这样
winpty npm.cmd init vite@2.8.0
or
npm init vite@latest
npm init vite@2.8.0
https://juejin.cn/post/7119455615840092173#heading-7
css: {
postcss: {
plugins: [
// css自动前缀兼容
autoprefixer({
overrideBrowserslist: ['Android 4.1', 'iOS 7.1', 'Chrome > 31', 'ff > 31', 'ie >= 8']
}),
postCssPxToRem({
// 自适应,px>rem转换
rootValue: 75, // 75表示750设计稿,37.5表示375设计稿
propList: ['*'], // 需要转换的属性,这里选择全部都进行转换
selectorBlackList: ['norem'] // 过滤掉norem-开头的class,不进行rem转换
})
]
}
},
module.exports = {
plugins: {
autoprefixer: {
//浏览器css自动兼容前缀配置
overrideBrowserslist: [
'Android 4.1',
'iOS 7.1',
'Chrome > 31',
'ff > 31',
'ie >= 8'
]
},
'postcss-pxtorem': {
rootValue: 37.5,
propList: ['*'],
selectorBlackList: ['.norem'] // 过滤掉.norem-开头的class,不进行rem转换
}
}
};
import 'amfe-flexible';
https://juejin.cn/post/6916304048505225223?utm_source=gold_browser_extension#heading-3
router.beforeEach(async (to, from, next) => {
if (!to.matched.length) {
next({
path: '/404'
});
}
// next({
// path: '/login',
// query: {
// redirect: to.fullPath // 将跳转的路由path作为参数,登录成功后跳转到该路由
// }
// })
console.log(to, 'to');
console.log(from, 'from');
next();
});
yarn add axios vite-plugin-md vue-i18n vite-plugin-pwa vue-router pinia vite-svg-loader dayjs qs @nutui/nutui
yarn add sass unplugin-auto-import unplugin-vue-components vite-plugin-style-import vite-plugin-mock mockjs vite-plugin-vue-setup-extend @vitejs/plugin-basic-ssl --dev