收藏
回答

IOS用户通过web-view无法跳转到微信公众号文章地址

框架类型 问题类型 API/组件名称 终端类型 微信版本 基础库版本
小程序 Bug web-view 微信iOS客户端 最新 3.8.10

小程序后台已关联公众号,在安卓机里面可以正常跳转并且显示页面,但是到了IOS可以跳转,但是无法正常显示图片,以下是IOS跳转的页面

示例代码:

(1)链接跳转函数:

// 跳转到外部链接

goToExternalLink(externalLinks, title) {

if (!externalLinks) {

uni.showToast({ title: '链接信息有误', icon: 'none' });

return;

}

// 检查用户登录状态,未登录时提示先登录

if (!this.isUserLoggedIn) {

this.showLoginRequiredModal('查看外部链接需要先登录');

return;

}

// 使用智能导航函数处理外部链接

smartNavigate(externalLinks, title || '外部链接');

},

(2)smartNavigate函数:

export function smartNavigate(url, title = '外部链接', options = {}) {

  if (!url) {

    console.error('跳转URL不能为空');

    return;

  }

  if (url.startsWith('/')) {

    uni.navigateTo({

      url: url,

      success: () => console.log('[导航] 内部页面跳转成功'),

      fail: (err) => {

        uni.switchTab({

          url: url,

          fail: (err2) => console.error('[导航] switchTab也失败', err2)

        });

      }

    });

    return;

  }

  if (isConfiguredDomain(url)) {

    uni.navigateTo({

      url: `/pages/webview/webview?url=${encodeURIComponent(url)}&title=${encodeURIComponent(title)}`,

      success: () => console.log('[导航] WebView页面打开成功', url),

      fail: (err) => console.error('[导航] WebView页面打开失败', err)

    });

  } else {

    const proxyUrl = `https://xcx.wdlipo.com/app/api/proxy?url=${url}`;

    uni.navigateTo({

      url: `/pages/webview/webview?url=${encodeURIComponent(proxyUrl)}&title=${encodeURIComponent(title)}`,

      success: () => console.log('[导航] 代理WebView页面打开成功'),

      fail: (err) => console.error('[导航] 代理WebView页面打开失败', err)

    });

  }

}

(3)web-view跳转逻辑:

  onLoad(options) {

    if (options.url) {

      this.url = decodeURIComponent(options.url);

    } else {

      uni.showToast({

        title: '缺少URL参数',

        icon: 'none',

        duration: 2000

      });

    }

    if (options.title) {

      this.title = decodeURIComponent(options.title);

      uni.setNavigationBarTitle({

        title: this.title

      });

    }

  },

<template>

  <view class="webview-container">

    <web-view :src="url" ></web-view>

  </view>

</template>

回答关注问题邀请回答
收藏

2 个回答

  • 那一抹微笑😊穿透阳光
    那一抹微笑😊穿透阳光
    2025-10-29

    你这个和小程序这边无关啊,应该是公众号那边设置了什么

    2025-10-29
    有用
    回复 2
    • 小辣鸡
      小辣鸡
      2025-10-29
      不应该啊,安卓可以正常显示,IOS就不行了
      2025-10-29
      回复
    • 那一抹微笑😊穿透阳光
      那一抹微笑😊穿透阳光
      2025-10-29回复小辣鸡
      ios要求不一样啊,那很正常啊
      2025-10-29
      回复
  • 智能回答 智能回答 本次回答由AI生成
    2025-10-29
    有用
登录 后发表内容