Given these exports in a plugin
(在插件中给出这些导出)
// Imagine these inner functions are written somewhere
export const WindowFunctions={
maximize: maximizeFunction,
minimize: minimizeFunction
}
export const FileFunctions={
open: openFileFunction,
close: closeFileFunction
}
// Imaging 20 other exports here
export default{
WindowFunctions,
FileFunctions,
// imagine those 20 other exports here too
}
When using require, you could access them with
(使用require时,您可以使用)
const {maximize} = require('yourPlugin').WindowFunctions
How can this be achieved with import
instead?
(如何通过import
来实现呢?)
So far I have been doing this
(到目前为止,我一直在这样做)
import {WindowFunctions} from 'yourPlugin'
const maximize = WindowFunctions.maximize
Is there a nicer way to import these?
(有没有更好的方法来导入这些?)
Thanks
(谢谢)
ask by Trevor translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…