导入时自定义模块“未找到”-VueJS项目

问题描述 投票:0回答:1

我在源代码树上创建了一个名为RegisterPayMonthlyDialog.vue的自定义组件。问题在于,当将其导入视图Monthly.vue时,npm无法找到该模块。

错误

 ERROR  Failed to compile with 1 errors                                                         11:06:29 PM

This dependency was not found:

* @/components/dialogs/RegisterPayMonthlyDialog in ./node_modules/cache-loader/dist/cjs.js??ref--12-0!./nod
e_modules/babel-loader/lib!./node_modules/vuetify-loader/lib/loader.js??ref--18-0!./node_modules/cache-load
er/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/views/Monthly.vue?vue&type
=script&lang=js&

To install it, you can run: npm install --save @/components/dialogs/RegisterPayMonthlyDialog

源树

enter image description here

Monthly.vue

<template>
  <v-container class="pa-5">
    <h3>Mensalidades</h3>
  </v-container>
</template>

<script>
import RegisterPayMonthlyDialog from "@/components/dialogs/RegisterPayMonthlyDialog"; // can't find it

export default {
  name: "Monthly",
  components: {
    RegisterPayMonthlyDialog
  },
  data() {
    return {
      showPayMonthyDialog: false
    };
  }
};
</script>

RegisterPayMonthlyDialog.vue

<template>
  <div class="text-center">
    <v-dialog v-model="show" width="500">
      <v-card>
        <v-card-title primary-title class="title">Pagamento de mensalidade</v-card-title>
      </v-card>
    </v-dialog>
  </div>
</template>s

<script>
export default {
  name: "RegisterPayMonthlyDialog",
  data() {
    return {};
  },
  props: {
    show: Boolean
  }
};
</script>
javascript vue.js npm
1个回答
1
投票

您输入错误。参见下面的代码

您正在导入名为RegisterPayMonthlyDialog的文件,但您的文件名为RegisterPayMonhtlyDialog

要解决它,请将文件名更改为RegisterPayMonthlyDialog.vue

并像这样导入

import RegisterPayMonthlyDialog from "@/components/dialogs/RegisterPayMonthlyDialog"
© www.soinside.com 2019 - 2024. All rights reserved.