Javascript 带子组件的Vue组件

Javascript 带子组件的Vue组件,javascript,html,vue.js,vue-component,Javascript,Html,Vue.js,Vue Component,我是vue的新手,我正在尝试创建一个可重用组件,其中包含一个网格 我已经创建了两个组件,一个用于标题和一些文本的主要功能,另一个用于每个网格项。但是,我得到以下15:9错误“GridItem”在编译期间没有定义任何未定义 这是我的密码: FeaturesWGrid.vue <template> <div class="bg-gray-200 py-20 px-6 xl:px-40"> <div class="text-center mb-16">

我是vue的新手,我正在尝试创建一个可重用组件,其中包含一个网格

我已经创建了两个组件,一个用于标题和一些文本的主要功能,另一个用于每个网格项。但是,我得到以下15:9错误“GridItem”在编译期间没有定义任何未定义

这是我的密码:

FeaturesWGrid.vue

<template>
  <div class="bg-gray-200 py-20 px-6 xl:px-40">
    <div class="text-center mb-16">
      <h1 class="text-xl lg:text-2xl uppercase font-bold mb-2">{{ mainTitle }}</h1>
      <p class="text-base">{{ mainText }}</p>
    </div>

    <div class="px-2">
      <div class="flex flex-col lg:flex-row flex-wrap">
        <slot></slot>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "FeaturesWGrid",

  props: {
    mainTitle: String,
    mainText: String
  }
};
</script>
GridItem.vue

<template>
  <div class="w-full lg:w-1/3 px-2">
    <div
      class="bg-white shadow-md mb-4 p-8 rounded transition duration-300 ease-in-out transform hover:-translate-y-1 hover:bg-gray-400"
    >
      <i class="fas text-gray-900 text-3xl pb-4" :class="icon"></i>
      <h2 class="text-xl font-medium mb-2">{{ gridTitle }}</h2>
      <p class="text-sm">{{ gridText }}</p>
    </div>
  </div>
</template>

<script>
export default {
  name: GridItem,
  props: {
    gridTitle: String,
    icon: String,
    gridText: String
  }
};
</script>
Page.vue

<template>
  <section>
    <!-- hero -->
    <div class="w-full h-64 bg-auto bg-no-repeat bg-center lg:bg-cover relative mc-hero">
      <div class="w-full h-full flex flex-col justify-center items-center text-white px-6">
        <div class="hero-text rounded text-center py-8 px-12">
          <p class="text-base lg:text-md uppercase font-medium">Powerful, secure &amp; affordable</p>
          <h1 class="text-xl md:text-3xl lg:text-5xl uppercase font-bold">Minecraft hosting</h1>
          <p class="text-base lg:text-md">Plans suitable for all budgets.</p>
        </div>
      </div>
    </div>

    <!-- all features -->
    <FeaturesWGrid mainTitle="Features" mainText="All plans come with the following as standard">
      <GridItem
        icon="fa-server"
        gridTitle="FTP Access"
        gridText="With full FTP access you can upload and install files to enhance your playing experience quickly."
      />
      <GridItem
        icon="fa-user-clock"
        gridTitle="24/7 Support"
        gridText="We know that issues can arise at any point, so our support is available around the clock."
      />
      <GridItem
        icon="fa-users"
        gridTitle="Support for subusers"
        gridText="We know that worlds need to be managed so we allow you to have as many admins you need."
      />
      <GridItem
        icon="fa-users"
        gridTitle="MySQL Databases"
        gridText="All products we offer come with a unlimited MySQL databases, to store all of your records safely."
      />
      <GridItem
        icon="fa-toolbox"
        gridTitle="Scheduled Tasks"
        gridText="We allow you to create scheduled tasks giving you more flexibility in how you handle your server."
      />
      <GridItem
        icon="fa-hdd"
        gridTitle="Daily Backups"
        gridText="All products come with free daily backups to keep all of your data safe so you don't need to worry."
      />
    </FeaturesWGrid>
  </section>
</template>

<script>
import FeaturesWGrid from "../components/FeaturesWGrid";
import GridItem from "../components/GridItem";

export default {
  name: "MinecraftHosting",

  components: {
    FeaturesWGrid,
    GridItem
  }
};
</script>

<style scoped>
.mc-hero {
  background-image: url("../assets/images/mc-background.png");
}
.hero-text {
  background-color: var(--whiteOpacity);
  backdrop-filter: blur(6px);
}
</style>

任何帮助都很好。

组件的名称必须是字符串,请参见下面的代码:

GridItem.vue

<template>
  <div class="w-full lg:w-1/3 px-2">
    <div
      class="bg-white shadow-md mb-4 p-8 rounded transition duration-300 ease-in-out transform hover:-translate-y-1 hover:bg-gray-400"
    >
      <i class="fas text-gray-900 text-3xl pb-4" :class="icon"></i>
      <h2 class="text-xl font-medium mb-2">{{ gridTitle }}</h2>
      <p class="text-sm">{{ gridText }}</p>
    </div>
  </div>
</template>

<script>
export default {
  name: GridItem,
  props: {
    gridTitle: String,
    icon: String,
    gridText: String
  }
};
</script>
... 导出默认值{ 名称:'GridItem',//在此处更改 道具:{ gridTitle:String, 图标:字符串, gridText:字符串 } };