赞
踩
export const getInitToDoLists = (localUrl) => {
fetch(localUrl)
.then(res => res.json())
.then(data => {
console.log('local data', data)
})
}
错误提示信息如下:
解决方案:
将对饮的json数据置于public目录下,使用fetch时再传入相对于public的文件url即可;或者使用process.env.PUBLIC_URL+’/finename.json’(来源于create react app文档using the public folder)
原因推测:
If you need to use a file from src or node_modules, you’ll have to copy it there to explicitly specify your intention to make this file a part of the build. ——
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。