### [小程序有扫一扫的功能吗](https://www.prosaas.cn/article/16874) **Published:** 2020-03-20T09:19:07 **Author:** 5201314 **Excerpt:** 小程序有扫一扫的功能吗小程序具有扫码功能,具体使用方法可以参考微信小程序开发文档,这里只做简单的介绍。小程序调… ![](https://img.php.cn/upload/article/000/000/040/5e7489232c104164.jpg) **小程序有扫一扫的功能吗** 小程序具有扫码功能,具体使用方法可以参考微信小程序开发文档,这里只做简单的介绍。 小程序调用扫码功能可以使用**wx.scanCode(Object object)** 参数如下: | 属性 | 类型 | 默认值 | 必填 | 说明 | 最低版本 | | --- | --- | --- | --- | --- | --- | | onlyFromCamera | boolean | false | 否 | 是否只能从相机扫码,不允许从相册选择图片 | 1.2.0 | | scanType | Array.98c455a79ddfebb79781bff588e7b37e | \['barCode', 'qrCode'\] | 否 | 扫码类型 | 1.7.0 | | success | function | | 否 | 接口调用成功的回调函数 | | | fail | function | | 否 | 接口调用失败的回调函数 | | | complete | function | | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | | 示例代码: // 允许从相机和相册扫码 wx.scanCode({ success (res) { console.log(res) } }) // 只允许从相机扫码 wx.scanCode({ onlyFromCamera: true, success (res) { console.log(res) } }) PHP中文网,大量小程序开发,欢迎学习! 以上就是小程序有扫一扫的功能吗的详细内容,更多请关注知企PROSAAS其它相关文章! **Categories:** 后端开发 ---