1、popup組件placement設置top沒有生效?
可以用offset屬性將popup往下邊偏移一下 來規避
2、組件攜帶自定義參數的接口是哪個?
參考鏈接:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/ts-universal-attributes-custom-property-V5#customproperty
customProperty
customProperty(name: string, value: Optional<Object>)
設置組件的自定義屬性。自定義組件不支持設置自定義屬性。
卡片能力: 從API version 12開始,該接口支持在ArkTS卡片中使用。
3、HarmonyOS 如何主動隱藏輸入彈框?
可以給外層容器添加個點擊事件,在點擊事件中調用controller.stopEditing()方法移除輸入框焦點即可隱藏鍵盤
@Entry
@Component
struct TextInputExample {controller: TextInputController = new TextInputController();build() {Column() {TextInput({ controller: this.controller }) }.width('100%') .height('100%').onClick(()=>{ this.controller.stopEditing();})}
}
4、HarmonyOS webview字體大小設置?
使用defaultFontSize設置網頁的默認字體大小,參考文檔:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/ts-basic-components-web-V5#ZH-CN_TOPIC_0000001930757269__defaultfontsize9
5、HarmonyOS promptAction.openCustomDialog 彈窗如何寬度設置全屏寬?
目前promptAction.openCustomDialog 設置width(‘100%’), 系統會默認所在窗口寬度 - 左右 16vp
width參考鏈接:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/js-apis-promptaction-V5#ZH-CN_TOPIC_0000001884757698__customdialogoptions11%3Cbr%3E
demo:
import promptAction from '@ohos.promptAction';
import display from '@ohos.display'@Entry
@Component
struct Index {@State message: string = 'Hello World';build() {Button('點我').onClick(() => {DialogUtils.show(this)})}
}@Component
export struct TestComponent {build() {Row() {Text('彈窗內組件1彈窗內組件2彈窗內組件3彈窗內組件4彈窗內組件5彈窗內組件').height(200).textAlign(TextAlign.Center)}}
}export class DialogUtils {public static createOption(builder: CustomBuilder) {const option: promptAction.CustomDialogOptions = {builder: builder,isModal: true,alignment: DialogAlignment.Bottom,cornerRadius: 0,backgroundColor: Color.Red,width: "110%",autoCancel: false,}return option}public static show(context: Object,) {promptAction.openCustomDialog(DialogUtils.createOption(buildComp.bind(context)))}
}@Builder
function buildComp() {TestComponent()
}