Skip to content

Commit

Permalink
Merge pull request dcloudio#26 from q310550690/master
Browse files Browse the repository at this point in the history
增加二维码生成器
  • Loading branch information
hulinNeil committed Aug 23, 2018
2 parents ba48ecd + 8c18bd5 commit dde534b
Show file tree
Hide file tree
Showing 5 changed files with 160 additions and 0 deletions.
1 change: 1 addition & 0 deletions examples/hello-uniapp/components/qrcode/qrcode.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57 changes: 57 additions & 0 deletions examples/hello-uniapp/components/qrcode/qrcode.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<template>
<view class="qrcode">
<image class="image" v-if="img != ''" :src="img" :style="{ width: size+'px', height: size + 'px' }"/>
</view>
</template>
<script>
import QR from "./qrcode.js";
export default {
name: 'number-box',
props: {
val: {
type: String,
default: ''
},
size:{
type:Number,
default:100
}
},
data(){
return{
img:''
}
},
onUnload(){
},
methods: {
creatQrcode(){
let val = String(this.val)
if(val == ''){
return false
}
let img = QR.createQrCodeImg(val, {
size: parseInt(this.size)
})
this.img = img;
},
clearQrcode(){
this.img = '';
}
},
watch:{
size(newVal, oldVal){
if(newVal != oldVal){
this.size = newVal;
this.creatQrcode()
}
}
}
}
</script>
<style>
.qrcode{
display: flex;
justify-content: center;
}
</style>
5 changes: 5 additions & 0 deletions examples/hello-uniapp/pages.json
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,11 @@
"style": {
"navigationBarTitleText": "markdown富文本渲染"
}
}, {
"path": "pages/template/qrcode/qrcode",
"style": {
"navigationBarTitleText": "二维码生成"
}
}, {
"path": "platforms/app-plus/about/about",
"style": {
Expand Down
Loading

0 comments on commit dde534b

Please sign in to comment.