账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    nuxt.js如何使用 vue-qart 二维码插件
    • 见心书画许老师187533751612020-01-01 00:00
    14
    0

    nuxt版本

    版本是:2.0.0

    问题描述

    需要在nuxt框架中,使用vue-qart,但是有问题。

    问题出现的环境背景及自己尝试过哪些方法

    1.直接以vue环境下,使用安装使用vue-vue-qart,它会报错:【window is not undefined】。

    尝试解决方法,参考了官方文档:https://nuxtjs.org/faq/window...
    官方使用的方式是:
    if (process.browser) {
    require('external_library')
    }

    不过我按着这种方式,具体如何用不太清楚,下面是我的代码,依旧有问题
    <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.通过使用第三方模块方式使用vue-qart
    官方文档:https://zh.nuxtjs.org/guide/p...

    增加文件 plugins/qart.js
    import Vue from 'vue'
    import vueQart from 'vue-qart'
    Vue.use(vueQart)

    在 nuxt.config.js 内配置 plugins 如下:
    plugins: ["~/plugins/qart.js"]

    然后我在组件中尝试着使用了一下,我是直接在代码中用:<vue-qart></vue-qart>,不过他会报错:“Unknown custom element: <vue-qart> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
    ”,好像是我说没有注册组件什么的,但是我import引入vue-qart模块,还是不对~

    寻求可行的方案代码

    各位大佬有没有解决的方案~多谢了

    0
    打赏
    收藏
    点击回答
        全部回答
    • 0
    • AI智能解答 超级管理员 2023-04-06 12:061楼
      ? **答:** 使用 Nuxt.js 使用 vue-qart 二维码插件非常简单,只需要在项目中安装 vue-qart,然后在需要使用的组件中引入,并使用即可: ``` // 安装 vue-qart npm install vue-qart // 在需要使用的组件中引入 import VueQart from 'vue-qart' // 使用 export default { components: { VueQart } } ```
    • AI智能解答 超级管理员 2023-04-06 12:062楼
      ? **答:** 使用 Nuxt.js 使用 vue-qart 二维码插件非常简单,只需要在项目中安装 vue-qart,然后在需要使用的组件中引入,并使用即可: ``` // 安装 vue-qart npm install vue-qart // 在需要使用的组件中引入 import VueQart from 'vue-qart' // 使用 export default { components: { VueQart } } ```
    • AI智能解答 超级管理员 2023-04-06 12:033楼
      ? **答:** 使用 Nuxt.js 使用 vue-qart 二维码插件非常简单,只需要在项目中安装 vue-qart,然后在需要使用的组件中引入,并使用即可: ``` // 安装 vue-qart npm install vue-qart // 在需要使用的组件中引入 import VueQart from 'vue-qart' // 使用 export default { components: { VueQart } } ```
    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部