【发布时间】:2022-11-09 11:27:48
【问题描述】:
I'm using quasar 2/vue 3, and I try to call child method from parent layout, how do I achieve this?
app.vue
<template>
<router-view />
</template>
<script>
import { defineComponent } from "vue";
export default defineComponent({
name: "App",
});
</script>
routes.js
const routes = [
{
path: "/Quiz",
component: () => import("layouts/QuizLayout.vue"),
children: [{ path: "", component: () => import("src/pages/Quiz.vue") }],
meta: { requireAuth: false },
},
]
QuizLayout.vue
<template>
<q-page-container>
<router-view ref="view" />
</q-page-container>
</template>
<script setup>
import { ref, onMounted, toRefs, refs } from "vue";
const klik = () => {
this.$refs.view.debugg();
};
</script>
Quiz.vue
<template>
...
</template>
<script setup>
const debugg = () => {
console.log("function called");
};
</script>
I try to call debugg() from QuizLayout, I try this.$refs.view.debugg(); but its give error $refs is not defined, how can I achieve this?
标签: vuejs3 quasar-framework quasar
$refs. Also, make sure that the current route is actually the route that rendersQuiz.vue- VueRouter does not automatically navigate to a child route.