公文域设置值报错

阅读次数 86
await this.editor!.editor.Application.ActiveDocument.DocumentFields.Add({
      Name: 'lww',
      Range: { Start: 12, End: 16 },
      Hidden: false, // 是否隐藏,默认 false
      PrintOut: false, // 是否可打印,默认 true
      ReadOnly: true // 是否只读,默认 false
    });
    const documentField = await this.editor!.editor.Application.ActiveDocument.DocumentFields.Item({
      Name: 'lww'
      // Index: 1
    });
    const value = await documentField.Value;
    console.log(value);
    documentField.Value = `lww`;

在执行最后一行设置时报错

669951217773973504:1 Uncaught (in promise) promise reject: promise wrapper: error
Promise.then(异步)
writer.2972ada0.chunk.zh-CN.js:1 Error: CoreExecTimeout: >10000ms

看了内部API调用堆栈是把DocumentField的name当作 Index处理了。。。。 image.png image.png

1 Answers

image.png 你好,这边执行提供的代码可以正常设置公文域的值,然后是在readOnly设为true的时候再次修改才会出现上述报错,只读的时候是不能再次修改的,麻烦确认一下这里的报错时机是不是readOnly为true后再次修改值