ajax请求后端出现 Sorry, we need js to run correctly! 的问题,但是直接访问可以获得数据,没有问题
不知道是什么原因
//config文件代理部分
proxy: {
'/api': {
target: 'http://39.106.102.208',
changeOrigin: false,
},
},
//api 文件
export const _showEassy = async action => {
return await promise.request('/hospital/api.php', MethodType.GET, {
action,
});
};
//用ajax请求的文件
import { _showEassy, _searchEassy, _deleteEassy } from '../../utils/api';
async componentWillMount() {
const goeassyshow = [];
const show = await _showEassy('show_eassy');
for (let i = 0; i < show.data.length; i++) {
goeassyshow.push({
id: show.data[i].id,
title: show.data[i].title,
tag: show.data[i].types,
description: show.data[i].main,
content: show.data[i].text,
thumbnail: show.data[i].easyimage,
color: 'red',
path: `/article_manage/article-more/fix?id=${show.data[i].id}`,
});
}
this.setState({
eassyshow: goeassyshow,
});
}