我想从路径动态导入模块 importPath
vượt quaProps设置。
var importPath;
class MainComponent extends Component {
state = {}
render() {
// Set var importPath = "path_to_module here;"
// importPath = this.props.myModulePath
return (
);
}
}
export default MainComponent;
Sau đó:
class ComponentToImport extends Component {
ToastExample: (async () => {
await import (this.props.revPath)
})()
async sayHiFromJava() {
this.state.ToastExample.showJ('Awesome', ToastExample.SHORT);
}
render() {
return ();
}
}
Làm thế nào tôi có thể giải quyết vấn đề này?
提前谢谢大家。
如何附加 ToastExample
hiện hữuimport ToastExample from importPath;
至await import("importPath");
这样我就可以return();
gia hạn
我已经尝试过:
class ComponentToImport extends Component {
ToastExample: (async () => {
await import (this.props.revPath)
})()
async sayHiFromJava() {
this.state.ToastExample.showJ('Awesome', ToastExample.SHORT);
}
render() {
return ();
}
}
但我收到错误:
error: bundling failed: index.js: index.js:Invalid call at line 28: import(_this.props.myComponentPath)
Tôi là một lập trình viên xuất sắc, rất giỏi!