[英]Cannot import typescript modules inside main.ts on Vue.js app
I am building a simple vue.js app using typescript,I am trying to do some routing and bring the route file to main.ts
but when I run the app I get the following error:我正在使用打字稿构建一个简单的 vue.js 应用程序,我正在尝试进行一些路由并将路由文件带到
main.ts
但是当我运行该应用程序时出现以下错误:
These relative modules were not found:
* ./plugins/vuetify in ./src/main.ts
* ./router/routerIndex in ./src/main.ts
* ./store/index in ./src/main.ts
main.ts is in src/main.ts
main.ts在
src/main.ts
indexRouter.ts is in src/router/indexRoute.ts
indexRouter.ts在
src/router/indexRoute.ts
main.ts主文件
import Vue from 'vue';
import vuetify from "./plugins/vuetify";
import App from "./App.vue"
import store from "./store/index";
import VueRouter from 'vue-router'
import router from "./router/routerIndex"
Vue.config.productionTip = false
Vue.use(VueRouter);
new Vue({
store,
vuetify,
render: h => h(App),
router
}).$mount("#app");
routerIndex.ts路由器索引.ts
import Vue from "vue";
import Router from "vue-router";
import Home from "../components/pages/Home.vue";
Vue.use(Router);
const routes = [
{
name: "home",
path: "/",
component: Home
}
]
const router = new Router({ mode: "history", routes });
export default router;
tsconfig.json配置文件
{
"compilerOptions": {
"target": "ES2019",
"module": "commonjs",
"outDir": "./dist",
"strict": true,
"esModuleInterop": true,
"sourceMap": true,
"experimentalDecorators": true,
"forceConsistentCasingInFileNames": true
},
"include": [
"src/**/*",
"src/**/*.ts",
"src/**/*.tsx",
"src/**/*.vue",
"tests/**/*.ts",
"tests/**/*.tsx"
],
}
This project was not installed with Vue@Cli, it was installed with npm by the person who created the project.这个项目不是用 Vue@Cli 安装的,它是由创建项目的人用 npm 安装的。
I am new to both Vue
and Typescript
so I might be screwing up something.我是
Vue
和Typescript
所以我可能会Typescript
一些事情。
Thanks in advance.提前致谢。
You can install @vue/cli, then open the vue ui
, import the your project in the vue ui and then using the ui again download typescript plugin.您可以安装@vue/cli,然后打开
vue ui
,在vue ui
中导入您的项目,然后再次使用ui 下载typescript 插件。 Tell me if anything is unclear:)如果有什么不清楚的请告诉我:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.