[英]Getting export error in my project ( what's the correct way of exporting ? )
我的项目中出现导出错误。
正确的出口方式是什么?
这是什么问题呢?
错误:
开发服务器返回的响应错误代码:500
网址: http : //192.168.43.244 : 8081 / index.android.bundle?platform = android&dev = false&hot = false&minify = false
正文:{“ from”:“ E:\\ reactNative \\ chat \\ awsm \\ camera \\ icons.js”,“ to”:“ ../ assets / 512”,“ message”:“无法解析模块
../assets/512
E:\\\\reactNative\\\\chat\\\\awsm\\\\camera\\\\icons.js
../assets/512
:无法将`E:\\ reactNative \\ chat \\ awsm \\ assets \\ 512'解析为文件夹:它不包含软件包,也没有索引文件“,”名称“:” UnableToResolveError“,”类型“:” UnableToResolveError“,”错误“:[{}]} processBundleResult BundleDownloader.java:172 access $ 100 BundleDownloader.java:38 execute BundleDownloader.java: 108 emitchunk MultipartStreamReader.java:69 readAllParts MultipartStreamReader.java:116 onResponse BundleDownloader.java:96 execute RealCall.java:135 run NamedRunnable.java:32 runWorker ThreadPoolExecutor.java:1112 run ThreadPoolExecutor.java:587 run Thread.java:818
index.js
const globe = require('./globe-icon.png');
const postit = require('./post-it-icon.png');
export { globe,
postit}
icons.js
import { globe,
postit} from '../assets/512'
const icons =[
{ name: 'Notes', image: postit },
{ name: 'Earth', image: globe }
]
export { icons }
我相信您的export
情况不错,但import
情况不正确。 您需要指定导入源。 所以:
import { globe, postit }
应该替换为
import { globe, postit } from './whatever'
'./whatever'
应为'.'
如果文件在同一文件夹中。
该文档-https: //developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Statements/import
似乎../assets/512
文件夹的相对路径错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.