本文主要是介绍ionic4 中扫一扫的实现,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
扫一扫是调用微信的接口,所以代码写完,需要发布到外网,形成小程序,在手机上测试才能知道是否成功。
实现:
1.安装weixin-js-sdk插件
在终端安装插件:cnpm install weixin-js-sdk.
然后就获取了require方法。
2.引用
把引用写在ts代码里即可
declare var $: any;
declare var require: NodeRequire;
3.调用微信接口
public async presentLoadding() {this.bookInfo = [];const loader = await this.loadingCtrl.create({message: '扫一扫启动中...',duration: 2000});await loader.present();this.Scan();}
Scan() {this.bookInfo = [];let qrResult: string;const urlCurrentPage = encodeURIComponent(encodeURIComponent(location.href.split('#')[0]));const url = 'https://dmsdbj.com/kernel-web/weChat/scan/' + urlCurrentPage;this.http.get(url).subscribe(res => {const wx = require('weixi
这篇关于ionic4 中扫一扫的实现的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!