Enforce the vp unit for the width, height, and size universal attributes for adaptation to the screen width of different devices.
const WIDTH_SIZE = 100;
@Entry
@Component
struct Index {
build() {
Row() {
Column() {
Button('btn').size({ width: 40, height: '20vp' })
}.width(WIDTH_SIZE)
.height('100vp')
}
.height('100%')
.width('100%')
.justifyContent(FlexAlign.Center)
}
} @Entry
@Component
struct Index {
build() {
Row() {
Column() {
Button('btn').size({ width: '40px', height: '20px' })
}.width('100px')
.height('100px')
}
.height('100%')
.width('100%')
.justifyContent(FlexAlign.Center)
}
} plugin:@cross-device-app-dev/recommended plugin:@cross-device-app-dev/all
For details about how to configure Code Linter check rules, see Code Linter.