HarmonyOS 报错Cannot find name 'backgroundColor'. Did you mean the instance member 'this.backgroundColor'?
自定义的CardView想在调用的地方设置backgroundColor等属性值,无法设置报以上错误。
// 自定的CardView
@Component
export struct CardView {
@BuilderParam private content: () => void // 控件占位符
build() {
Column() {
this.content()
}
.shadow({
radius: 6,
color: Color.Grey,
offsetX: 0,
offsetY: 0
})
.padding({
left: 30,
right: 30,
top: 20,
bottom: 20
})
.borderRadius(6)
.alignItems(HorizontalAlign.Start)
}
}
// 调用CardView
CardView() {
Row() {
}.width("100%")
}
.backgroundColor(Color.White) // 这里报错:Cannot find name 'backgroundColor'. Did you mean the instance member 'this.backgroundColor'?
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
- 22.
- 23.
- 24.
- 25.
- 26.
- 27.
- 28.
- 29.
- 30.
- 31.
- 32.
HarmonyOS
赞
收藏 0
回答 1
相关问题
HarmonyOS Cannot find name 'ESObject'
768浏览 • 0回复 待解决
getContext 提示错误,Cannot find name 'getContext'
1545浏览 • 1回复 待解决
HarmonyOS 如何实现一个ViewModelFactory,当前会报错cannot find name 'T'
429浏览 • 0回复 待解决
Span设置backGroundColor不生效是为什么?
1073浏览 • 1回复 待解决
HarmonyOS bindContextMenu中设置backgroundColor不生效
921浏览 • 1回复 待解决
HarmonyOS http请求报错could not find host name
661浏览 • 1回复 待解决
HarmonyOS CustomDialog中backgroundColor无法设置透明颜色
736浏览 • 1回复 待解决
在TS文件里使用Concurrent注解报红,提示Cannot find name 'Concurrent'
1695浏览 • 1回复 待解决
openharmony源码编译报错importerror:cannot import name
9298浏览 • 1回复 已解决
HarmonyOS Web设置 .backgroundColor(Color.Transparent)还是白色的
494浏览 • 1回复 待解决
HarmonyOS entry module中引用hsp报错cannot find record...
2597浏览 • 1回复 待解决
将一个文件,从原文件下移出后,Cannot find name 'CustomDialogExample',无法引用
729浏览 • 1回复 待解决
HarmonyOS BLECharacteristic类型的全局变量可选变量如何设置,提示Cannot find name 'BLECharacteristic'.应该导入什么包
471浏览 • 1回复 待解决
HarmonyOS 同一个颜色值,为啥backgroundColor和linearGradient显示的不一样
692浏览 • 1回复 待解决
DevEco Studio出现Gradle sync failed: Cannot find JAR错误
5965浏览 • 1回复 待解决
HarmonyOS源码编译错误 importerror:cannot import name
5324浏览 • 1回复 已解决
DevEco Studio 升级报错 Cannot find JAR 'jaxb-impl-2.3.2.jar' required by module 'gradle-resources-s3
8432浏览 • 2回复 已解决
Cannot find module '@ohos.application.Ability' or its corresponding type declarations.
13492浏览 • 1回复 待解决
安装pcre报错“You need a C++ compiler for C++ support.”
3340浏览 • 1回复 待解决
参考示例如下: