調用 js function - daniel-qa/Vue GitHub Wiki
調用 js function
import { post, fetch } from '@/until/http.js'
export default {
//获取版本
versions(data) {
return post('/core/system-info', data)
},
}
import axios from 'axios';
axios.defaults.timeout = 1000000; //设置超时时长
axios.defaults.baseURL = '';
/**
* 封装post请求
* @param url
* @param data
* @returns {Promise}
*/
export function post(url, params) {
let data = {};
data.method = url;
data.params = params;
data.lang = localStorage.getItem('local');
return new Promise((resolve, reject) => {
axios.post(url, params)
.then(response => {
resolve(response.data);
// this.$Message.success('数据访问成功!');
}, error => {
reject(error);
//this.$Message.error('数据访问错误!');
})
})
}