一多特性必须使用系统断点判断是否开启,不能通过设备类型、设备方向或是否可折叠等属性来判断。
// code-linter.json5
{
"rules": {
"@cross-device-app-dev/one-multi-breakpoint-check": "warn"
}
} @Entry
@Component
struct ItemComponent {
private currentWidthBreakpoint: string = '';
build() {
// 必须使用断点进行判断
if (this.currentWidthBreakpoint === 'lg') {
}
}
} import { display } from '@kit.ArkUI';
import { deviceInfo } from '@kit.BasicServicesKit';
@Entry
@Component
struct ItemComponent {
build() {
// 使用设备类型、是否可折叠等属性进行判断,告警
if (deviceInfo.deviceType === 'phone' && display.isFoldable()) {
}
}
} plugin:@cross-device-app-dev/recommended plugin:@cross-device-app-dev/all
Code Linter代码检查规则的配置指导请参考Code Linter代码检查(ArkTS/TS)。