1、全局安裝tki-qrcode插件
npm i tki-qrcode
2、查看下載插件后的版本信息
3、在頁面中引入tki-qrcode
import tkiQrcode from "tki-qrcode"
export default {
components: {
tkiQrcode
}
}
4、生成二維碼整體代碼
<template>
<view class="content">
<view class="text-area">
<text class="title">{{title}}</text>
</view>
<view>
<view class="qrimg">
<tki-qrcode ref="qrcode" :val="val" :size="size" :unit="unit" :background="background" :foreground="foreground"
:pdground="pdground" :lv="lv" :onval="onval" :loadMake="loadMake"
@result="qrR" />
</view>
</view>
</view>
</template>
<script>
import tkiQrcode from "tki-qrcode"
export default {
components: {
tkiQrcode
},
data() {
return {
val: '生成二維碼內(nèi)容', //要生成二維碼的值
size: 250, // 二維碼的大小 單位為rpx
background: '#ffffff', //背景色
foreground: '#000000',
pdground: '#000000', //角標(biāo)色
icon: '', //二維碼圖標(biāo)
iconsize: 30, //二維碼圖標(biāo)大小
lv: 3, //二維碼容錯級別
onval: true, //val值變化時自動重新生成二維碼
unit: 'upx',
loadMake: true, //組件加載完成后自動生成二維碼
src: '',
showLoading: true, //loading
loadingText: 'loading內(nèi)容', //loading內(nèi)容
title: 'Hello'
};
},
methods:{
qrR(){
console.log("二維碼生成")
}
}
}
</script>
<style>
.content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.text-area {
display: flex;
justify-content: center;
}
.title {
font-size: 36rpx;
color: #8f8f94;
}
</style>
5、效果展示
此樣式是平時黑色二維碼樣式,此為打過馬賽克的二維碼(不打馬賽克博客無法展示圖片,無奈(O~O)
文章來源:http://www.zghlxwxcb.cn/news/detail-492092.html
注:文章來源地址http://www.zghlxwxcb.cn/news/detail-492092.html
- 二維碼中的內(nèi)容可綁定鏈接和其他內(nèi)容值
- 根據(jù)自己的需要進(jìn)行val值的綁定
到了這里,關(guān)于tki-qrcode插件二維碼的生成的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!