【问题标题】:This in a Quasar project and node module not able to access this.$q这在 Quasar 项目和节点模块中无法访问。$q
【发布时间】:2020-11-09 18:13:18
【问题描述】:

我无法在节点模块中访问 Quasar 的 this.$q 并将其用作 Quasar CLI 中的 boot 插件。

我有一个组件,我可以在其中启动我的 QLayout,当我将 console.log(this.$q) 放在该组件的已创建部分中时,我可以访问 this.$q,我可以访问该信息。但收到 QLayout 无法访问相同信息的各种错误。

Vue warn]: Error in data(): "TypeError: Cannot read property 'screen' of undefined"

found in

---> <QLayout>
       <DlLayoutMenu> at node_modules/frontend-modules/src/components/system/components/DlLayoutMenu.vue
         <App> at src/App.vue
           <Root>
vue.runtime.esm.js?794d:1888 TypeError: Cannot read property 'screen' of undefined
    at VueComponent.data (QLayout.js?2d21:37)
    at VueComponent.mergedDataFn (vue.runtime.esm.js?794d:1219)
    at getData (vue.runtime.esm.js?794d:4748)
    at initData (vue.runtime.esm.js?794d:4705)
    at initState (vue.runtime.esm.js?794d:4642)
    at VueComponent.Vue._init (vue.runtime.esm.js?794d:5006)
    at new VueComponent (vue.runtime.esm.js?794d:5154)
    at createComponentInstanceForVnode (vue.runtime.esm.js?5593:3283)
    at init (vue.runtime.esm.js?5593:3114)
    at createComponent (vue.runtime.esm.js?5593:5978)

所以我在QLayout.js 中的35 上放置了一个调试器并手动调试此对象具有的内容,但它完全不同,并且不包含密钥$q

【问题讨论】:

    标签: vue.js quasar-framework quasar


    【解决方案1】:

    我可以修复它,我花了一段时间才明白发生了什么。但是我用 cli 创建了两个 Quasar 项目。父项目也包含类星体和模块。没有指定并且实际上没有在模块中真正使用类星体,它从模块node_modules 中获取了 QLayout。我可以看到在QLayout.js 中硬编码console.log 并调试它实际使用的是哪个。我真的不知道这是怎么做到的。然而,将所有与 Quasar 相关的模块都放在模块之外使其工作。这有一些缺点,如果我想在没有它的父包的情况下在那个包中做一些特别的事情,它就行不通......

    【讨论】:

      【解决方案2】:

      我遇到了同样的问题,解决 - 通过 git pack docs 重新安装

      ttps://github.com/quasarframework/vue-cli-plugin-quasar

      【讨论】:

      猜你喜欢
      • 2018-07-22
      • 2021-06-07
      • 2020-05-28
      • 2021-10-23
      • 1970-01-01
      • 2014-07-01
      • 1970-01-01
      • 2020-07-23
      • 1970-01-01
      相关资源
      最近更新 更多