diff --git a/zh-cn/application-dev/reference/apis/js-apis-inputmethod.md b/zh-cn/application-dev/reference/apis/js-apis-inputmethod.md index 613a9701bad2595f022673cca38e12665e575db1..143fa70d4dcb3ee3c09541540534f7cc8d9b27fb 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inputmethod.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inputmethod.md @@ -72,7 +72,48 @@ getInputMethodSetting(): InputMethodSetting ```js var InputMethodSetting = inputMethod.getInputMethodSetting(); ``` +## inputMethod.switchInputMethod9+ +switchInputMethod(target: InputmethodProperty, callback: AsyncCallback<boolean>): void; + + +**系统能力**:SystemCapability.Miscservices.InputMethodFramework + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + |target | InputmethodProperty | 是 | 传入要切换的目标输入法。 | + | callback | AsyncCallback<boolean> | 是 | 返回输入法切换是否成功。 | + + +**示例:** + +```js + inputMethod.switchInputMethod({packageName:"com.ohos.inputApp", methodId:"InputDemoService"}).then(res => { + prompt.showToast({message:"切换输入法成功" + this.imeList[this.flag].packageName, duration: 200}); + }); +``` + +switchInputMethod(target: InputmethodProperty): Promise<boolean> + + +**系统能力**: SystemCapability.Miscservices.InputMethodFramework + +**返回值:** + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + |target | InputmethodProperty | 是 | 传入要切换的目标输入法。 | + +**示例:** + + +```js + inputMethod.switchInputMethod({packageName:"com.ohos.inputApp", methodId:"InputDemoService"}).then(res => { + prompt.showToast({message:"切换输入法成功" + this.imeList[this.flag].packageName, duration: 200}); + }); +``` ## InputMethodController 下列API示例中都需使用[getInputMethodController](#getInputMethodController)回调获取到InputMethodController实例,再通过此实例调用对应方法。