开发者在编写ArkUI代码时,想要提前预览下所编写的组件的效果,下述哪个组件可以使用DevEco Studio Previewer正常预览?( )
(A)@Preview @Component struct TitleSample { @StorageProp('title') title: string = 'PlaceHolder'; build() { Text(this.title) } }
(B) @Preview @Component struct LinkSample { @Link message: string; build() { Text(this.message) } }
(C) @Preview @Component struct ConsumeSample { @Consume name: string; build() { Text(this.name) } }
(D) import { add } from 'libnative.so'; @Preview @Component struct NativeSample { count: number = add(1, 2); build() { Text(current count is ${this.count}) } }
(B) link变量没有初始化 C Consumer没有提供Provider D 没有add具体方法,需要自定义mock
参考答案
继续答题:下一题


更多鸿蒙高级认证试题
- 1一个应用的一个UIAblity,其exported字段配置为false,以下哪个场景可以拉起这个UIAbility ( )
- 2在moduleA(HAP类型)中有一个图片名为image.png,在moduleB(HAR类型)也存在一个图片名为image.png,而moduleA依赖于moduleB,那么在moduleA的编译产物hap包中,image.png存在情况是:( )
- 3已知下列代码PageOne页面为navigation中的某一子页面,依次点击PageOne页面中toPageTwo按钮,PageTwo页面中toPageOne按钮,此时点击get按钮获取全部名为name的NavDestination页面的位置索引为 ( )
- 4当前您在开发一个ArkTS、Stage模型的HarmonyOS工程,关于当前ArkTS工程目录结构,下列选项说法错误的是?( )
- 5下面持续交付&持续部署描述哪个是正确的 ( )
- 6项目中涉及多个类的继承与重写。为了快速实现子类对父类方法的重写,小华想利用DevEco Studio提供的便捷功能来提高开发效率。他了解到,通过一个特定的操作流程,可以直接依据父类的模板生成子类中需要重写的方法代码,而无需手动编写完整方法体,在DevEco Studio中,如何正确使用Override Methods功能来快速生成子类需要重写的方法代码 ( )