【问题标题】:Custom module "was not found" on import - VueJS project导入时“未找到”自定义模块 - VueJS 项目
【发布时间】:2020-01-30 01:09:10
【问题描述】:

我在我的源代码树上创建了一个名为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

源代码树

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>

【问题讨论】:

  • 除了错字之外,您在RegisterPayMonthlyDialog.vue 中的template 结束标记之后还有一个额外的s

标签: javascript vue.js npm


【解决方案1】:

您有一个拼写错误。见下面的代码

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

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

并像这样导入它

import RegisterPayMonthlyDialog from "@/components/dialogs/RegisterPayMonthlyDialog"

【讨论】:

    猜你喜欢
    • 2018-12-20
    • 1970-01-01
    • 2019-10-14
    • 2020-01-07
    • 1970-01-01
    • 2020-12-27
    • 1970-01-01
    • 2021-07-04
    • 1970-01-01
    相关资源
    最近更新 更多