【发布时间】:2020-08-01 09:47:07
【问题描述】:
尝试使用 vue.js 和 vue-router.js 演示路由,但得到 SyntaxError "Cannot use import statement outside a module"。我正在尝试从正确的位置导入 vue。下面是树打印出来的。我没有正确导入 vue。谢谢。
树打印出来:
.
├── index.html
├── index.js
├── js
│ ├── vue-router.js
│ └── vue.js
└── src
├── App.vue
├── AppRouter.vue
├── ArticlesPage.vue
└── HomePage.vue
index.html
<!DOCTYPE html>
<html>
<head>
<title>Vue app</title>
</head>
<body>
<div id="app">
</div>
</body>
<script src="js/vue.js"></script>
<script src="js/vue-router.js"></script>
<script src="index.js"></script>
</html>
index.js
import Vue from "./js/vue"; // errors here
import App from "./src/App";
const app = new Vue({
el: "#app",
render(h) {
return h(App);
}
});
【问题讨论】:
-
你遇到了什么错误?
-
试试
import Vue from 'vue';
标签: javascript vue.js