本文介绍了DriveApp folder.getUrl()是否已更改或损坏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下函数返回url的空值
function test(){

  var folderiter = DriveApp.getFolders (); 
while(folderiter.hasNext()){
var folder = folderiter.next();
Logger.log(folder.getName()+url:+ folder.getUrl())


}

}

解决方案

但是这里有一个解决方法:
$ b $ pre $ function myFunction(){

var folderiter = DriveApp.getFolders() ;
while(folderiter.hasNext()){
var folder = folderiter.next()
var folderId = folder.getId()//将新行添加到您的代码中
/ /DocsList.getFolderById(folderId).getURL()将url作为变量
var url = DocsList.getFolderById(folderId).getUrl()
Logger.log(folder.getName()+url :+ url)//修改为使用变量而不是方法


}

}

我用我自己的文件夹和文件测试了这个,但我无法确认它适用于每种文件/文件夹类型。但是,如果它对你有帮助,你能接受答案吗?


The following function returns null values for urlfunction test() {

    var folderiter = DriveApp.getFolders();
          while (folderiter.hasNext()) {
          var  folder = folderiter.next();
          Logger.log(folder.getName()+" url:"+folder.getUrl())


  }

}

解决方案

It's broken, as DavidF said, but here's a workaround:

function myFunction() {

  var folderiter = DriveApp.getFolders();
  while (folderiter.hasNext()) {
            var  folder = folderiter.next()
            var  folderId = folder.getId()//new line added to your code
            //DocsList.getFolderById(folderId).getURL() works to get url as variable
            var  url = DocsList.getFolderById(folderId).getUrl()
            Logger.log(folder.getName()+" url:"+url)//modified to use variable instead of method


  }

}

I did test this with my own folders and files, but I can't confirm it works with every file/folder type. However, if it helps you, can you accept the answer?

这篇关于DriveApp folder.getUrl()是否已更改或损坏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-17 12:16