我最近浏览了https://github.com/ory/editor/blob/master/packages/ui/src/Trash/index.js#L89
找到了一种我不明白的论点。以下是完整的代码:
const types = ({ editor }: { editor: Editor }) => {
const plugins = [
...Object.keys(editor.plugins.plugins.layout),
...Object.keys(editor.plugins.plugins.content)
].map(
(p: string) =>
editor.plugins.plugins.content[p].name ||
editor.plugins.plugins.layout[p].name
)
if (editor.plugins.hasNativePlugin()) {
plugins.push(editor.plugins.getNativePlugin()().name)
}
return plugins
}争论的意义是什么?叫什么来着?
发布于 2018-10-19 20:55:01
它意味着函数将接收具有编辑器属性的对象,并具有编辑器的类型。
有关更多信息,您可以检查https://flow.org/en/
发布于 2018-10-19 21:10:45
这里有两个部分。
editor属性。
{ editor }如果没有类型定义,它看起来就像这样。如果您知道,您只需要传递对象的编辑器,就可以销毁它。
// Passing and working with the whole object
const fn1 = ( obj ) => {
const editor = obj.editor;
console.log( editor );
};
// Destructing the object and only use the editor property
// Basically the same as fn1 without the whole obj.
const fn2 = ( { editor } ) => {
console.log( editor );
};
const obj = {
editor: 'Editor',
};
fn1( obj );
fn2( obj );
https://stackoverflow.com/questions/52899390
复制相似问题