Google Doc 更新一个文档 替换多个变量

2022-01-24 17:49:04 浏览数 (1)

代码语言:javascript复制
gapi.client.request({
        method: 'POST',
        path: `https://docs.googleapis.com/v1/documents/${docId}:batchUpdate`,
        body: {
          requests: [
            {
              replaceAllText: {
                replaceText: '蓑笠翁',
                containsText: {
                  text: '${oldMan}',
                  matchCase:true
                }
              }
            },
            {
              replaceAllText: {
                replaceText: '雪',
                containsText: {
                  text: '${snow}',
                  matchCase:true
                }
              }
            }
          ]
        }
      }).then(res => {
        printLog(`更新文档成功`, 'text-success')
        console.log(res)
        downLoadDocFile(res.result.documentId)
      })

0 人点赞