安装插件
npm i qrcode -s
引入插件
import Vue from 'vue'
import App from './App.vue'
import QRCode from 'qrcode'
Vue.use(QRCode)
Vue.prototype.$QRCode = QRCode
new Vue({
el: '#app',
a:'123',
render: h => h(App)
})
使用
<template>
<div id="app">
<canvas id="canvas"></canvas>
</div>
</template>
<script>
import popup from "./components/popup.vue";
export default {
components: { popup },
name: "app",
data() {
return {};
},
mounted: function () {
var cavas = document.getElementById("canvas")
this.$QRCode.toCanvas(canvas,'https://www.xiangcaowuyu.net')
},
computed: {
},
methods: {
},
};
</script>
<style>
#app {
font-family: "Avenir", Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
}
</style>
转Java了,哈哈