How to use the vue-qart QR code plug-in for nuxt.js

nuxt version

version is: 2.0.0

problem description

needs to be in the nuxt framework, but there is a problem with using vue-qart,.

the environmental background of the problems and what methods you have tried

1. Directly in the vue environment, using the installation to use vue-vue-qart, will report an error: [window is not undefined].

try the solution, referring to the official document: https://nuxtjs.org/faq/window..
the official way is:
if (process.browser) {
require ("external_library")
}

but I don"t know exactly how to use it in this way. Here is my code, and there are still problems
< template >

.
<div class="articleShow">
    <vue-qart :config="config"></vue-qart>
</div>

< / template >
< script >

import VueQart from "vue-qart"
export default {
    data(){
        return {
            config: {
                value: "https://baidu.com",
                imagePath: "http://menvscode.com/public/img/logo.png",
                filter: "color"
            }
        }
    },
    components:{},
    created(){
        if (process.browser) {
            require("vue-qart")
        }
    }
}

< / script >

2. Use vue-qart by using third-party modules
official documentation: ide/plugins/-sharp%E4%BD%BF%E7%94%A8-vue-%E6%8F%92%E4%BB%B6" rel=" nofollow noreferrer "> https://zh.nuxtjs.org/guide/p.

add files plugins/qart.js
import Vue from "vue"
import vueQart from" vue-qart"
Vue.use (vueQart)

configure plugins within nuxt.config.js as follows:
plugins: ["~ / plugins/qart.js"]

then I tried to use it in the component. I used it directly in the code: < vue-qart > < / vue-qart >, but he would report an error: "Unknown custom element: < vue-qart >-did you register the component correctly?" For recursive components, make sure to provide the "name" option.
", it seems that I said there is no registered component or something, but my import introduced the vue-qart module, but it is still not correct ~

.

seek a feasible scheme code

do you guys have a solution ~ Thank you

Dec.02,2021

well, I have also encountered this problem, but it has been solved ~


it is recommended to use nuxt to generate QR code images

Menu