我也嘗試過 navigator.canshare,但它在 chrome 桌面上作業。它給出了未定義的。
if (navigator.share) {
navigator.share({
title: 'Lot Quality Report',
text: 'Lot Link -',
url: 'https://www.google.com'
})
.then(() => console.log('Successful share')) //this is for sucess
.catch((error) => console.log('Error sharing', error));
} else {
console.log('Share not supported on this browser, do it the old way.');
alert('Share not supported on this browser, do it the old way.');
}
此代碼不適用于 mac os 中的 google chrome 桌面。我可以使用任何替代方法在 google chrome 桌面上運行共享功能。
uj5u.com熱心網友回復:
我找到了答案,在 mac os 中我們需要更改瀏覽器的設定。網址 - https://winaero.com/chrome-to-get-web-share-api-support-on-desktop/
點擊 - chrome://flags/#web-share >> 啟用 >> 重新啟動瀏覽器
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/525370.html
上一篇:制作動態搜索表單以停止膨脹控制器
