Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/420.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript '中的错误;附录列表项';-谷歌插件_Javascript_Google Apps Script_Google Docs Api_Google Developer Tools - Fatal编程技术网

Javascript '中的错误;附录列表项';-谷歌插件

Javascript '中的错误;附录列表项';-谷歌插件,javascript,google-apps-script,google-docs-api,google-developer-tools,Javascript,Google Apps Script,Google Docs Api,Google Developer Tools,我正在尝试将listItem从一个google文档复制到其他文档 代码如下: var activeDocID=DocumentApp.getActiveDocument().getId(); var targetBody = DocumentApp.openById(activeDocID).getBody(); for (i = 0; i < docCopy.getBody().getNumChildren(); i++) { var element =do

我正在尝试将listItem从一个google文档复制到其他文档

代码如下:

  var activeDocID=DocumentApp.getActiveDocument().getId();
  var targetBody = DocumentApp.openById(activeDocID).getBody();

  for (i = 0; i < docCopy.getBody().getNumChildren(); i++) 
  {

    var element =docCopy.getBody().getChild(i).copy();
    var type = element.getType();

    if (type == DocumentApp.ElementType.PARAGRAPH) 
    {
         if (element.asParagraph().getNumChildren() != 0 && element.asParagraph().getChild(0).getType() == DocumentApp.ElementType.INLINE_IMAGE) 
         {
           var blob = element.asParagraph().getChild(0).asInlineImage().getBlob();    
           targetBody.appendImage(blob);
         }
         else 
           targetBody.appendParagraph(element.asParagraph());
    }
    else if( type == DocumentApp.ElementType.TABLE){
      targetBody.appendTable(element);
    }
    else if( type == DocumentApp.ElementType.INLINE_IMAGE) {
      var image = element.asInlineImage().getBlob();    
      targetBody.appendImage(image);
    }
    else if( type == DocumentApp.ElementType.LIST_ITEM){
      targetBody.appendListItem(element);
    }

    else if( type == DocumentApp.ElementType.HORIZONTAL_RULE) {
      targetBody.appendHorizontalRule();
    }
    else if( type == DocumentApp.ElementType.PAGE_BREAK) {
      targetBody.appendPageBreak();
    }
  }
var-activeDocID=DocumentApp.getActiveDocument().getId();
var targetBody=DocumentApp.openById(activeDocID.getBody();
对于(i=0;i
我得到了一个错误:

“服务不可用:文件”(השרתלאזן:ססם)


如何解决此问题?

抛出错误时,
元素
的值是多少?元素是带有图像的ListItem。如果我从源代码中删除图像,它就正常工作了。你能分享一下它的价值吗?此处没有足够的信息来了解引发此错误的原因,因为可能有许多不同的原因。如何查看其值?请将其放入日志中,可以是
Logger.log()
console.log()
并在常规日志或stackdriver日志中查看。抛出错误时,
元素的值是多少?元素是带有图像的ListItem。如果我从源代码中删除图像,它就正常工作了。你能分享一下它的价值吗?此处没有足够的信息来了解引发此错误的原因,因为可能有许多不同的原因。如何查看其值?将其放入日志中,可以是
Logger.log()
console.log()
,然后在常规日志或stackdriver日志中查看。