1.通過callapp-lib插件實現喚起app功能
npm install –save callapp-lib
2.頁面中使用
(1)引入callapp-lib包 import CallApp from ‘callapp-lib‘;
(2)實例化過程中,需要傳遞一個 options 對象給類,設置options參數
const options = {
scheme: { // 用來配置 URL Scheme 所必須的那些字段
protocol: '', //APP 協議,就是你要打開的 APP 的標識
host: ''
},
intent: {
scheme: '',
package: ''
},
appstore: '', // appstore的下載地址
yingyongbao: '', // 應用寶的下載地址
fallback: '' // 喚端失敗後跳轉的地址
}
this.callAppLib = new CallAppLib(options);
(3)校驗喚起app需要的url
function checkUrl(url) {
if (url.indexOf('#') !== -1) {
return url.replace(/#/g, 'hashrouter');
}
return url;
}
let path = window.location.href;
url = checkUrl(path);
(4)調用喚端功能
callAppLib.open({ path: url });