import FileBase from 'react-file-base64';
将三点指示器悬停在 VS Code 中后出现错误。
除了插入图像的 filebase64 部分之外,我的设置已经成功(其他输入字段已成功插入到 MongoDB 云中)。
module "d:/nodejs/memories_project/client/node_modules/react-file-base64/build/build.min" Could not find a declaration file for module 'react-file-base64'. 'd:/nodejs/memories_project/client/node_modules/react-file-base64/build/build.min.js' implicitly has an 'any' type. Try
npm i --save-dev @types/react-file-base64
if it exists or add a new declaration (.d.ts) file containingdeclare module 'react-file-base64';
ts(7016)
这是我的package.json
的依赖项:
"dependencies": {
"@material-ui/core": "^4.9.10",
"@material-ui/icons": "^4.9.1",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.3.2",
"@testing-library/user-event": "^7.1.2",
"axios": "^0.19.2",
"moment": "^2.27.0",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-file-base64": "^1.0.3",
"react-redux": "^7.1.3",
"react-scripts": "3.4.1",
"redux": "^4.0.5",
"redux-thunk": "^2.3.0"
},
最佳答案
如果该值未保存在数据库中,则意味着该值为空或不存在。检查模型文件(/server/models/)中的字段名称是否与表单文件(/client/src/components/)中的字段名称相同。
现在错误消息与实际问题无关。
发生这种情况是因为react-file-base64不提供任何类型。要消除错误,您需要在 .d.ts 文件中声明该模块。
为此,请使用以下代码在项目根目录(package.json 所在位置)中创建一个 .d.ts 文件(例如 index.d.ts):
declare module 'react-file-base64';
或者你可以声明所有
declare module '*';
关于reactjs - 如何解决这个 MERN stack filebase64 错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66258644/