HarmonyOS 鸿蒙Next 开发工具的etsLint和开发文档实际规范不符,请问该如何处理呢
HarmonyOS 鸿蒙Next 开发工具的etsLint和开发文档实际规范不符,请问该如何处理呢 在开发工具里,如果将子组件被@Prop注解了的变量本地初始化值,开发工具将会报错, 但是在3.1/4.0的开发文档里,是写明被@Prop注解了的变量是可以被本地初始化值的,编译代码后,也能成功运行程序,这个报错看着很别扭,请问大家遇到这个问题是如何解决的呢
更多关于HarmonyOS 鸿蒙Next 开发工具的etsLint和开发文档实际规范不符,请问该如何处理呢的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html
我们这边测试是没有问题的,api大于等于9就不会报错,api8及以下还是会报错,您新建个API 9的工程再试试看呢
更多关于HarmonyOS 鸿蒙Next 开发工具的etsLint和开发文档实际规范不符,请问该如何处理呢的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html
感谢感谢,重建了新项目以后,已经没有问题了,
版主大大,又遇到@ObjectLink
注解了参数以后,etsLint报错了,详情请见4楼,附上了代码,
import { A, B } from ‘./model’;
@Componentstruct Index {
@State b: B = new B(“View B”, new A(“View A1”))
build() {
Column() {
ViewA({ a: this.b.a, name: this.b.name })
ViewA({ a: new A(“View A1”), name: this.b.name })
Button(“replace B”).onClick(() => {
this.b = new B(“replace B”, new A(“A2”))
}).margin({ bottom: 10 })
Button(“update B name”).onClick(() => {
this.b.name = “update B name”
}).margin({ bottom: 10 })
Button(“replace A”).onClick(() => {
this.b.a = new A(“replace A”);
}).margin({ bottom: 10 })
Button(“update A”).onClick(() => {
this.b.a.name = “update A”;
}).margin({ bottom: 10 })
}.width(“100%”)
.height(“100%”)
.justifyContent(FlexAlign.Center)
.alignItems(HorizontalAlign.Center)
}
}
@Componentstruct ViewA {
@ObjectLink a: A;
@Prop name: string = “view A”
build() {
Text(${this.name}, a name:${this.a.name}
)
}
}
@Observedexport class A {
name: string;
constructor(name: string) {
this.name = name;
}
}
@Observedexport class B {
name: string;
a: A;
constructor(name: string, a: A) {
this.name = name;
this.a = a;
}
}
在以上代码中, ViewA({ a: this.b.a, name: this.b.name }) 这行代码etsLint有报错提示,内容为:Assigning the ‘@State’ decorated attribute ‘b’ to the ‘@ObjectLink’ decorated attribute ‘a’ is not allowed. ,但是一样是可以正常编译到模拟器里进行运行,且不会报错崩溃。
请问这个我这边该如何解决呢?
这个已知问题,已经在修改了哈,
晚上回家试试,
已经下载DevEco Studio 4.0 Beta2版本,但是问题仍未解决,麻烦版主大大看看下面的图片,里面的HarmonyOS版本是否符合要求,
按版主大大建议,已经下载了最新开发工具,当前的开发工具版本已经是DevEco Studio 4.0 Beta2
HarmonyOs版本见图,但是错误依然未解决,请版主大大能详细说明下如何修复
![cke_3168.png]