最近的移动端项目用到的一些不常用的小技巧:
直接上干货vue-cli3 中webpackServer代理
首先,.env.development文件设置`VUE_APP_baseApi = /api`
其次,vue.config.js文件设置devServer: {
proxy: {
'/api': {
target: 'http://xxx/api',
changeOrigin: true,
ws: true,
pathRewrite: {
'^/api': ''
}
}
}
}日期格式化(yyyy-mm-dd hh:mm)dateFormatter(val) {
const YYYY = val.getFullYear()
const MM = val.getMonth() + 1 < 10 ? "0" + (val.getMonth() + 1) : val.getMonth() + 1;
const DD = val.getDate() < 10 ? "0" + val.getDate() : val.getDate();
const hh = val.getHours() < 10 ? "0" + val.getHours() : val.getHours();
const mm = val.getMinutes() < 10 ? "0" + val.getMinu