跳转
是否可以处理指定的 uri,主要用于检测是否已安装对应的 App。
launch
weixin://
true 可以处理 url, false 不可以
关闭当前窗口
可选
需要返回给父窗口的数据
ymx.close() .then(() => { console.log('成功'); }) .catch((e) => { alert(`失败 ${JSON.stringify(e)}`); }); 复制
ymx.close() .then(() => { console.log('成功'); }) .catch((e) => { alert(`失败 ${JSON.stringify(e)}`); });
// 带返回值的关闭,在 ymx.open() 的 onResult 函数中接收处理返回值ymx.close({ hello: 'world 世界', year: 2026}).then(() => { console.log('成功');}).catch((e) => { alert(`失败 ${JSON.stringify(e)}`);}); 复制
// 带返回值的关闭,在 ymx.open() 的 onResult 函数中接收处理返回值ymx.close({ hello: 'world 世界', year: 2026}).then(() => { console.log('成功');}).catch((e) => { alert(`失败 ${JSON.stringify(e)}`);});
拉起第三方应用,不要求在 query schemes 中注册 url scheme,只要安装了对应应用即可拉起。
ymx.launch({ uri: 'https://xw.qq.com/'}).then(() => { console.log('成功');}).catch((e) => { alert(`失败 ${JSON.stringify(e)}`);}); 复制
ymx.launch({ uri: 'https://xw.qq.com/'}).then(() => { console.log('成功');}).catch((e) => { alert(`失败 ${JSON.stringify(e)}`);});
ymx.launch({ uri: 'weixin://'}).then(() => { console.log('成功');}).catch((e) => { alert(`失败 ${JSON.stringify(e)}`);}); 复制
ymx.launch({ uri: 'weixin://'}).then(() => { console.log('成功');}).catch((e) => { alert(`失败 ${JSON.stringify(e)}`);});
ymx.launch({ uri: 'tel://1801234'}).then(() => { console.log('成功');}).catch((e) => { alert(`失败 ${JSON.stringify(e)}`);}); 复制
ymx.launch({ uri: 'tel://1801234'}).then(() => { console.log('成功');}).catch((e) => { alert(`失败 ${JSON.stringify(e)}`);});
在新窗口中打开链接
ymx.open({ url: 'https://xw.qq.com/'}).then(() => { console.log('成功');}).catch((e) => { alert(`失败 ${JSON.stringify(e)}`);}); 复制
ymx.open({ url: 'https://xw.qq.com/'}).then(() => { console.log('成功');}).catch((e) => { alert(`失败 ${JSON.stringify(e)}`);});
ymx.open({ url: 'https://xw.qq.com/', style: 'dialog', onResult: (result) => { // 关闭子窗口时返回的结果 ymx.close(result) console.log(result); }}).then(() => { console.log('成功');}).catch((e) => { alert(`失败 ${JSON.stringify(e)}`);}); 复制
ymx.open({ url: 'https://xw.qq.com/', style: 'dialog', onResult: (result) => { // 关闭子窗口时返回的结果 ymx.close(result) console.log(result); }}).then(() => { console.log('成功');}).catch((e) => { alert(`失败 ${JSON.stringify(e)}`);});
跳转