用H5打开微信小程序

从浏览器,QQ等场景,用H5链接打开微信小程序!!!

1、首先登录微信小程序后台:

  • 代码生成,通过在服务端调用 urlscheme.generate 接口生成 url sheme。
  • 微信小程序后台→工具→微信生成小程序URL Scheme;(不能生成永久URL Scheme,功能废弃)

2、生成后会获得一个链接

weixin://dl/news/?t=xxxxxxx

3、然后创建demo.html文件,建立页面,把weixin链接改成你上面得到的链接

<!DOCTYPE html>
<html lang="zh">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>H5打开小程序</title>
  </head>
  <body>
    <p style="text-align: center">自动跳转小程序</p>
  </body>
  <script>
  	//点击事件再说
    location.href = "weixin://dl/news/?t=xxxxxxx";
  </script>
</html>

4、把demo.html页面上传到你的服务器网站目录中,直接访问你的服务器链接
就会自动弹出是否跳转打开微信,然后会自动打开你的小程序。

5参考

生成Url Schene的方法

https://developers.weixin.qq.com/community/develop/doc/000aeab88a4ea0c5c89d81fde5b801?source=templateb&page=1#comment-list

https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/url-scheme/urlscheme.generate.html

猜你喜欢

转载自blog.csdn.net/weixin_46746389/article/details/127666357