Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use <script setup> get the parent component #9880

Closed
wb670 opened this issue Jun 30, 2021 · 2 comments
Closed

use <script setup> get the parent component #9880

wb670 opened this issue Jun 30, 2021 · 2 comments
Labels
bug/0-needs-info Need more info to reproduce kind/bug 🐞 Qv2 🔝 Quasar v2 issues

Comments

@wb670
Copy link

wb670 commented Jun 30, 2021

/quasar/src/utils/private/vm.js

when use <script setup>
the child component get the parent component, proxy.$parent is {}
must use proxy.$.parent.proxy get parent component

so i added && typeof vm.$parent !== 'object'

export function getParentVm (vm) {
  if (vm.$parent !== void 0 && vm.$parent !== null && typeof vm.$parent !== 'object') {
    return vm.$parent
  }

  vm = vm.$.parent

  while (vm !== void 0 && vm !== null) {
    if (vm.proxy !== void 0 && vm.proxy !== null) {
      return vm.proxy
    }

    vm = vm.parent
  }
}

or

import { useContext,getCurrentInstance } from 'vue'
const ctx = useContext()
@ts-ignore
const { proxy }  = getCurrentInstance()
ctx.expose(proxy)
@wb670 wb670 added kind/bug 🐞 Qv2 🔝 Quasar v2 issues labels Jun 30, 2021
@rstoenescu
Copy link
Member

Hi @wb670 ,

Can you create a reproduction repo pls? Trying to understand what you are doing.

@rstoenescu
Copy link
Member

Enhancement will be available in Quasar v2.3.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/0-needs-info Need more info to reproduce kind/bug 🐞 Qv2 🔝 Quasar v2 issues
Projects
None yet
Development

No branches or pull requests

2 participants