问题场景PageA 里面有组件B 组件B使用TextInput,第一次进来时候不显示内容,输入才显示参考以下示例代码引用TextInput自定义组件@Component struct TextInputComponent { @Link text: string controller: TextInputController = new TextInputController() build() { Column({ space: 20 }) { TextInput({ text: this.text, placeholder: '请输入手机号', controller:this.controller }) .placeholderColor(Color.Gray) .placeholderFont({ size: 14, weight: 400 }) .width(300) .type(InputType.Number) .borderWidth(0) .backgroundColor(Color.Transparent) .fontSize(16) .maxLength(11) .maxLines(1) .padding(5) .inputFilter("[0-9]") .onChange((value) => { this.text = value }) } .width('100%') .justifyContent(FlexAlign.Center) } } @Entry @Component struct ParentComponent { @State param : string = '13670187134' build() { Column() { TextInputComponent({text:this.param}); Divider().height(10) Text('输入框的内容:'+this.param) } } }
问题场景
PageA 里面有组件B 组件B使用TextInput,第一次进来时候不显示内容,输入才显示
参考以下示例代码引用TextInput自定义组件