在应用1内TextInput添加如下属性.copyOption(CopyOptions.LocalDevice)CopyOptions.LocalDevice,支持设备内复制。参考文档:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/ts-basic-components-textinput-V5\#copyoption9在应用2内TextInput添加如下回调.onPaste((value:string)=>{ this.text = value })参考文档:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/ts-basic-components-textinput-V5\#onpaste参考demo:应用1:@Entry @Component struct TextInputExample { @State text: string = '' @State positionInfo: CaretOffset = { index: 0, x: 0, y: 0 } @State passwordState: boolean = false controller: TextInputController = new TextInputController() build() { Column() { TextInput({ text: this.text, placeholder: 'input your word...', controller: this.controller }) .copyOption(CopyOptions.LocalDevice) .placeholderColor(Color.Grey) .placeholderFont({ size: 14, weight: 400 }) .caretColor(Color.Blue) .width('95%') .height(40) .margin(20) .fontSize(14) .fontColor(Color.Black) .onChange((value: string) => { this.text = value }) }.width('100%') } }应用2:@Entry @Component struct TextInputExample { @State text: string = '' @State positionInfo: CaretOffset = { index: 0, x: 0, y: 0 } @State passwordState: boolean = false controller: TextInputController = new TextInputController() build() { Column() { TextInput({ text: this.text, placeholder: 'input your word...', controller: this.controller }) .placeholderColor(Color.Grey) .placeholderFont({ size: 14, weight: 400 }) .caretColor(Color.Blue) .width('95%') .height(40) .margin(20) .fontSize(14) .fontColor(Color.Black) .onPaste((value:string)=>{ this.text = value }) .onChange((value: string) => { this.text = value }) Text(this.text) }.width('100%') } }
在应用1内TextInput添加如下属性.copyOption(CopyOptions.LocalDevice)
CopyOptions.LocalDevice,支持设备内复制。
参考文档:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/ts-basic-components-textinput-V5\#copyoption9
在应用2内TextInput添加如下回调
参考文档:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/ts-basic-components-textinput-V5\#onpaste
参考demo:
应用1:
应用2: