简体   繁体   English

如何在 nativescript-vue 弹出窗口中使用 vue 组件?

[英]How to use vue components in nativescript-vue popups?

I open the popup in some root component like this:我在一些根组件中打开弹出窗口,如下所示:

import parentt from "./parentt.vue";
.
.
.
this.$showModal(parentt, {
  fullscreen: true,
});

This is the content of parentt.vue :这是parentt.vue的内容:

<template>
  <StackLayout>
    <label text="parent" />
    <!-- <child /> -->
  </StackLayout>
</template>

<script>
  import child from "./child.vue";
  export default {
    components: [child],
  };
</script>

<style scoped>
</style>

This is the content of child.vue :这是child.vue的内容:

<template>
  <StackLayout>
    <label text="child" />
  </StackLayout>
</template>

<script>
  export default {};
</script>

<style scoped></style>

Whith <child /> commented out I get a popup with text parent in it.随着<child />注释掉,我得到一个带有文本父项的弹出窗口。

with <child /> being there I get a white screen. <child />在那里,我得到一个白屏。

I'm using many components in different places in my code, it's only here in a popup that it doesn't work.我在代码的不同位置使用了许多组件,它只是在弹出窗口中不起作用。

You have wrong bracket in components object in parentt.vue .您在parentt.vue的 components 对象中有错误的括号。 Components is an object, thus use braces instead of the square brackets.组件是一个对象,因此使用大括号而不是方括号。

So, the correct script section looks like in parentt.vue :因此,正确的脚本部分看起来像parentt.vue

<script>
  import child from "./child.vue";
  export default {
    components: {
       child
    },
  };
</script>

I recommend for detailed informations the official vue documentation我推荐vue 官方文档获取详细信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM