openExternalUrl.js 528 B

1234567891011121314151617181920
  1. export function openExternalUrl(url) {
  2. // #ifdef APP-PLUS
  3. plus.runtime.openURL(url, (error) => {
  4. if (error) {
  5. uni.showToast({ title: '打开失败', icon: 'none' });
  6. }
  7. });
  8. // #endif
  9. // #ifdef H5
  10. window.open(url, '_blank');
  11. // #endif
  12. // #ifdef MP-WEIXIN
  13. // 小程序只能使用 web-view 组件,这里可以跳转到一个内嵌 web-view 的页面
  14. uni.navigateTo({
  15. url: `/pages/webview/webview?url=${encodeURIComponent(url)}`
  16. });
  17. // #endif
  18. }