【发布时间】:2021-07-04 18:26:10
【问题描述】:
我在 Vue 3 中使用 laravel-mix,但出现以下错误:
ERROR in ./resources/js/components/App.vue 2:0-54
Module not found: Error: Can't resolve './App.js/?vue&type=script&lang=js' in './resources/js/components'
组件/App.vue
<template>
<div id="app">
<h1>Hello world</h1>
</div>
</template>
<script src="./App.js/"></script>
组件/App.js
export default {
name: "App",
};
在我之前使用 Vue 2 和 Laravel 7 的项目中,我没有遇到这些错误。现在我正在使用 Vue 3 和 Laravel 8,但不知道如何修复它。我已经安装了vue-loader 和vue-template-compiler,所以我想它应该可以工作。
Vue 3 是否允许从单独的 js 文件中导入脚本?在 Vue 2 中这是可能的(我喜欢将 HTML 与 JS 分开,因为我的编辑器存在一些问题,也为了更好的组织。)
【问题讨论】:
-
App.js 末尾的额外正斜杠应该在那里吗?看起来很可疑
<script src="./App.js/"></script> -
@steve16351 你是对的!感谢您指出了这一点;我自己没有想到这一点。如果您将其发布为答案,我会接受。
标签: laravel vuejs3 laravel-mix