1

我正在尝试使用 word api 将以下 html 插入到内容控件中我在 content.sync() 处收到 Richapi 错误

带有复选框的html代码:

<html>
<head>
</head>
<body>
<input type='checkbox'/>
<p>Click the checkbox</p>
</body>
</html>

没有复选框的html代码:

<html>
<head>
</head>
<body>
<p>Test Html</p>
</body>
</html>

用于将 html 插入内容控件的代码:

function InsertHtml() {
        Word.run(function (context) {

            var Html = "<html><head></head><body><input type='checkbox' />click on check box</body></html>";
            var DynamicControl = context.document.contentControls.getByTag("Test").getFirstOrNullObject();

            DynamicControl.insertHtml(Html, Word.InsertLocation.replace);     

            return context.sync().then(function () {
                {
                   write('Inserted HTML in the first content control.');
                }

            });
        })
            .catch(errorHandler);
    }

使用此代码,我在 context.sync() 处遇到错误

一般异常:一般异常

   at Anonymous function (https://appsforoffice.microsoft.com/lib/1.1/hosted/word-win32-16.01.js:24:287994)
   at T (https://appsforoffice.microsoft.com/lib/1.1/hosted/word-win32-16.01.js:24:220903)
   at x (https://appsforoffice.microsoft.com/lib/1.1/hosted/word-win32-16.01.js:24:220989)
   at t (https://appsforoffice.microsoft.com/lib/1.1/hosted/word-win32-16.01.js:24:220797)
   at l (https://appsforoffice.microsoft.com/lib/1.1/hosted/word-win32-16.01.js:24:219304)

相同的代码在 html 中按预期工作,它没有任何控件,如 Checkbox、Textbox、文本区域

4

0 回答 0