Open sfsoul opened 4 years ago
// Add a request interceptor
axios.interceptors.request.use(function (config) {
// Do something before request is sent
return config;
}, function (error) {
// Do something with request error
return Promise.reject(error);
});
// Add a response interceptor
axios.interceptors.response.use(function (response) {
// Any status code that lie within the range of 2xx cause this function to trigger
// Do something with response data
return response;
}, function (error) {
// Any status codes that falls outside the range of 2xx cause this function to trigger
// Do something with response error
return Promise.reject(error);
});
const express = require('express');
const app = express();
// 静态资源
app.use(express.static('public'));
// 起服务
app.listen(8888, () => {
console.log('listening on port 8888')
})
按需引入 Element UI
借助 babel-plugin-component 可实现按需引入,来达到减小项目体积的目的。
npm i babel-plugin-component -D
修改 .babelrc 文件: