index.wxml
<view class="container"> <button bindtap='getScancode'>扫一扫</button> </view>
index.js
const app = getApp() Page({ data: { result: '' },
onl oad: function() {
}, getScancode: function() { wx.scanCode({ onlyFromCamera: true,//只允许从相机扫码 success: (res) => { wx.navigateTo({ url: '../navigator/navigator?content=' + res.result }) var result = res.result; _this.setData({ result: result, }) } }) } })
要跳转的页面
navigator.wxml
<view> {{content}} </view>
navigator.js
Page({ data: { }, onl oad: function (options) { this.setData({ content: options.content }) },