[英]How to import an default exported object containing functions?
If one file has an export default:如果一个文件具有导出默认值:
export default {
function,
function2
}
How can I import these two functions in a separate file?如何在单独的文件中导入这两个函数? When I try restructuring it with当我尝试用
import { function, function2 } from 'path'
I get an error saying function is not exported from 'path'我收到一条错误消息,提示 function 未从“路径”导出
Since it's a default export, you will have to do it like below由于它是默认导出,因此您必须像下面那样进行
export default {
function1,
function2
}
import Path from 'path';
Path.function1();
Path.function2();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.