paragraphCollection.first在javascript这个词中应该怎么用api

How should paragraphCollection.first be used in the word javascript api

我为运行搜索的 word 创建了一个任务窗格加载项,并将显示搜索结果第一段的文本。 直到几天前,以下代码 运行 成功:

    function onGetFirstRangeParaClick() {

    var textToFind = "Word",
        range,
        paragraph;
    return Word.run(function (context) {

        var searchResults = context.document.body.search(textToFind, { matchWildCards: false });
        context.load(searchResults, "text");
        return context.sync()
            .then(function () {
                range = searchResults.items[0].getRange();
                context.load(range, "text, paragraphs");
                return context.sync();
            })
            .then(function () {
                paragraph = range.paragraphs.first;
                context.load(paragraph, "text");
                return context.sync();
            })
            .then(function() {
                $("#getFirstRangeParaResult").text(paragraph.text);
            });
    })
    .catch(onError);
}

但是现在抛出以下错误:

{"name":"OfficeExtension.Error","code":"GeneralException","message":"GeneralException","traceMessages":[],"debugInfo":{"errorLocation":"ParagraphCollection.first"},"stack":"GeneralException: GeneralException\n   at Anonymous function (https://appsforoffice.microsoft.com/lib/beta/hosted/word-win32-16.01.debug.js:8360:6)\n   at lib$es6$promise$$internal$$tryCatch (https://appsforoffice.microsoft.com/lib/beta/hosted/word-win32-16.01.debug.js:9595:8)\n   at lib$es6$promise$$internal$$invokeCallback (https://appsforoffice.microsoft.com/lib/beta/hosted/word-win32-16.01.debug.js:9605:8)\n   at lib$es6$promise$$internal$$publish (https://appsforoffice.microsoft.com/lib/beta/hosted/word-win32-16.01.debug.js:9581:9)\n   at lib$es6$promise$asap$$flush (https://appsforoffice.microsoft.com/lib/beta/hosted/word-win32-16.01.debug.js:9400:8)"}

我正在使用调试 PreviewCDN (//appsforoffice.microsoft.com/lib/beta/hosted/office.debug.js) 我是 运行 Office 版本 1610(内部版本 7466.2038)

我在 Api 文档中注意到 paragraphs.first 正在更改为 paragraphs.getFirst() 但它看起来还没有实现,就好像我更改为使用 getFirst() 我收到以下错误:

Object doesn't support property or method 'getFirst'  

我应该如何对 ParagraphCollection 使用 first 或 getFirst()?

感谢您使用预览版。正如您提到的那样,我们对某些属性进行了一些更改(即 obj.first、obj.last、obj.previous、obj.next 重命名为 getFirst()、getLast()、getLast () 和 getPrevious() 分别在所有支持这些功能的对象中。

如果您安装了最新的 Insider 慢速版本 (16.0.7571.2006),或者如果您使用的是 Insider 快速版本,那么您应该会看到所做的更改。预览 Office.js 将与版本 16.7571+

同步

谢谢,希望这能澄清发生了什么..