今天接到需求!!!想要从浏览器,QQ等场景,用H5链接打开微信小程序!!!
如何实现的,一番查阅后,让我带你实现吧!
ps:适用于非个人主体,微信内部的浏览器好像不行,你们自己试试。
1、首先登录微信小程序后台:
微信小程序后台→工具→微信生成小程序URL Scheme,根据你的需要填写,启动query参数可为空;
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页面上传到你的服务器网站目录中,直接访问你的服务器链接
就会自动弹出是否跳转打开微信,然后会自动打开你的小程序。