import config from './config.js';
import 'whatwg-fetch'
import toast from '../toast/index.js'
export default class Services {
constructor() {
}
static getInstance() {
if (!Services.instance) {
Services.instance = new Services();
return Services.instance;
}
return Services.instance;
}
post(action, data) {
toast.loading("加载中")
return fetch(config.base_url + action, {
method: 'POST',
body: JSON.stringify(data),
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
}
}).then(res => res.json())
}
get(action) {
toast.loading("加载中")
return fetch(config.base_url + action)
.then(response => {
return response.json()
})
}
get1(action) {
return fetch(action)
.then(response => {
return response.json()
})
}
}
export default {
base_url: '请求地址'
}
import React from 'react'
import ReactDOM from 'react-dom'
import Toast from './toast'
import './toast.css'
function createNotification() {
const div = document.createElement('div')
document.body.appendChild(div)
const notification = ReactDOM.render( < Toast / > , div)
return {
addNotice(notice) {
return notification.addNotice(