公告:所有在
2025 年 4 月 15 日之前注册使用 Earth Engine 的非商业项目都必须
验证是否符合非商业性质的资格条件,才能继续使用 Earth Engine。
ui.root.onResize
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
注册一个在脚本启动时以及每次浏览器窗口大小发生变化时触发的回调。系统将向其传递一个对象,该对象包含布尔值字段“is_mobile”“is_tablet”“is_desktop”“is_portrait”和“is_landscape”,以及数值字段“width”和“height”。
这些字段用于指明用户的设备是移动设备、平板电脑还是桌面设备、设备屏幕方向(竖屏或横屏),以及窗口的宽度和高度(以像素为单位)。如需查看设备指标的“宽度”和“高度”(dp) 部分,请访问 https://material.io/resources/devices/。
用法 | 返回 |
---|
ui.root.onResize(callback) | |
参数 | 类型 | 详细信息 |
---|
callback | 函数 | 窗口大小调整完毕后要触发的回调。系统会向回调传递一个包含设备信息的对象。 |
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-26。
[null,null,["最后更新时间 (UTC):2025-07-26。"],[[["\u003cp\u003eTriggers a provided function when the webpage loads or the browser window is resized.\u003c/p\u003e\n"],["\u003cp\u003eProvides details about the device used, such as whether it is a mobile, tablet, or desktop, its orientation (portrait or landscape), and the window's dimensions in pixels.\u003c/p\u003e\n"],["\u003cp\u003eUtilizes boolean fields ("is_mobile", "is_tablet", "is_desktop", "is_portrait", "is_landscape") and numeric fields ("width", "height") within a passed object to convey device information.\u003c/p\u003e\n"],["\u003cp\u003eCan be implemented using \u003ccode\u003eui.root.onResize(callback)\u003c/code\u003e, where \u003ccode\u003ecallback\u003c/code\u003e represents the function to be executed.\u003c/p\u003e\n"]]],[],null,["# ui.root.onResize\n\n\u003cbr /\u003e\n\nRegisters a callback that's fired when the script starts and whenever the browser window size changes. It will be passed an object with boolean fields \"is_mobile\", \"is_tablet\", \"is_desktop\", \"is_portrait\" and \"is_landscape\", and numeric fields \"width\" and \"height\".\n\n\u003cbr /\u003e\n\nThese fields indicate whether a user's device is mobile, tablet or desktop, the device orientation (portrait or landscape), and the width and height of the window in pixels. See the Width and Height (dp) section of device metrics at https://material.io/resources/devices/.\n\n| Usage | Returns |\n|------------------------------|---------|\n| `ui.root.onResize(callback)` | |\n\n| Argument | Type | Details |\n|------------|----------|------------------------------------------------------------------------------------------------------------------------------|\n| `callback` | Function | The callback to fire after the window has been resized. The callback is passed an object with the information of the device. |"]]