您可以添加依赖关系/libs/wcm/foundation/components/utils/AuthoringUtils.js然后调用AuthoringUtils.isTouch并AuthoringUtils.isClassic检查它当前是否处于联系状态或经典模式.例如,您的JS Use API看起来如下所示.
"use strict";
use(["/libs/wcm/foundation/components/utils/AuthoringUtils.js"], function (AuthoringUtils) {
if (AuthoringUtils.isTouch) {
// do something
} else {
// do something else
}
// rest of the things
}
Run Code Online (Sandbox Code Playgroud)