gpt4 book ai didi

css - 为 Apps 脚本 UI 服务设置单独的 CSS 文件

转载 作者:太空宇宙 更新时间:2023-11-04 13:34:09 25 4
gpt4 key购买 nike

使用 Apps Script UI 服务,可以使用各种类的 setStyleAttributes() 方法设置 CSS 样式。

setStyleAttributes

可以使用setStyleAttributes() 同时设置多个CSS 样式属性。 CSS 样式设置可以放入一个key:value 对象并赋值给一个变量,然后该变量可以在setStyleAttributes 方法中使用。

var cssHome = {"color":"red", "cursor": "pointer", "textDecoration" : "underline", "fontSize": "small", "font-family":"Arial Black"}
var menuHome = app.createMenuItem('HOME')
menuHome.setStyleAttributes(cssHome)

现在我所有的代码和变量都在一个 .gs 文件中,所有内容都在 doGet 函数中。有没有办法将 CSS 放入另一个文件并调用它?

最佳答案

如果您愿意将 CSS 创作为键值对,您可以将它们包装在一个单独的函数中并在赋值时调用它,或者您可以将其存储在 Drive 和 UrlFetch 中的平面文件中。这两种解决方案都不允许传统的 CSS 创作,但你会问吗。

对于 doGet,前者可能更可取。您可以通过包装另一个 GS 并将其作为库引用来跨多个脚本重用此样式。

如果您使用 HtmlService 而不是 UiService,您的 CSS 选项会按照惯例增加。

关于css - 为 Apps 脚本 UI 服务设置单独的 CSS 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23166332/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com