# 微信开发

# 微信内置图片查看

/**
 * 调用微信内置浏览器查看图片功能
 * current - 查看图片的 url
 * urls - 查看图片 url 集合
 */
function imagePreview(current, urls) {
    
    // 解析相对路径
    var anchor = document.createElement('a');
    function parseUrl(url) {
        anchor.href = url;
        return anchor.href;
    }

    current = parseUrl(current);
    for (var i = 0; i < urls.length; i++) {
        urls[i] = parseUrl(urls[i]);
    }

    // 调用 WeixinJSBridge imagePreview
    typeof WeixinJSBridge !== 'undefined' && WeixinJSBridge.invoke('imagePreview', {
        current: current,
        urls: urls
    }, function() {});
}

# 判断微信 UserAgent

判断微信客户端的那些坑 (opens new window)

Last Updated: 5/14/2022, 11:38:45 AM