运行此代码片段后,我将以下数据结构打印到控制台
let editorDelta: DeltaStatic | undefined = editor?.getContents()
console.log(editorDelta)
安慰:
ops: [
{
attributes: {
underline: true,
italic: true,
color: "#000fff",
background: "#fff000",
bold: true
},
insert: "this"
},
{
attributes: {
underline: true,
italic: true,
color: "#000fff",
background: "#fff000",
bold: true
},
insert: "that"
},
]
我正在尝试为此数据创建一个类型变量,但遇到了一些问题。下面的界面正在工作,但我想为一些更嵌套的数据(如属性和插入分机)定义类型。
interface DeltaStatic {
ops?: object[]
}
我尝试过但不起作用的其他一些示例。
interface DeltaStatic {
ops?: {
attributes: {
underline: boolean,
italic: boolean,
color: string,
background: string,
bold: boolean
},
insert: string
}[]
}
interface DeltaStatic {
ops?: [
{
attributes: {
underline: boolean,
italic: boolean,
color: string,
background: string,
bold: boolean
},
insert: string
}
]
}