vue3+ts项目在vscode中爆红提示修复

问题描述:
新搭建的vue3+ts项目,在vscode中打开,已经安装的的依赖文件也会提示红线
如下图:
image.png
在vscode中的tsconfig.json修改配置如下:
image.png
代码如下:

{
  "compilerOptions": {
    "target": "ES2020",
    "useDefineForClassFields": true,
    "module": "ESNext",
    "lib": ["ES2020", "DOM", "DOM.Iterable"],
    "skipLibCheck": true,
    // "types": ["element-plus/global"],

    /* Bundler mode */
    "moduleResolution": "node",
    "allowImportingTsExtensions": true,
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "preserve",
    "baseUrl": ".",
    "allowJs": true,
    /* Linting */
    "strict": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "noFallthroughCasesInSwitch": true
  },
  "types": ["vite/client", "element-plus/global","unplugin-icons/types/vue"],
  "skipLibCheck": true /* Skip type checking all .d.ts files. */,
  "allowSyntheticDefaultImports": true /* 允许默认导入 */,
  "forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
  "include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"],
  "references": [{ "path": "./tsconfig.node.json" }]
}

  • 4
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
Vue 3 + TypeScript项目使用,您可以按照以下步骤进行操作: 1. 安装Vue CLI:如果您还没有安装Vue CLI,可以使用以下命令进行安装: ``` npm install -g @vue/cli ``` 2. 创建项目:使用Vue CLI创建一个新的Vue 3项目,可以运行以下命令: ``` vue create my-project ``` 3. 选择配置:在创建项目的过程,您将被提示选择一些配置选项。请确保选择TypeScript作为您的项目的语言。 4. 安装依赖:项目创建完成后,进入项目目录并安装依赖项。在命令行运行以下命令: ``` cd my-project npm install ``` 5. 创建Vue组件:现在,您可以开始在Vue 3 + TypeScript项目创建组件。打开 src 目录,并创建一个新的 .vue 文件,例如 `HelloWorld.vue`。 ```vue <template> <div> <h1>{{ greeting }}</h1> </div> </template> <script lang="ts"> import { defineComponent } from 'vue'; export default defineComponent({ data() { return { greeting: 'Hello, World!' }; } }); </script> ``` 6. 使用组件:在您的应用程序使用该组件,在 `App.vue` 导入并注册 `HelloWorld.vue` 组件。 ```vue <template> <div id="app"> <HelloWorld /> </div> </template> <script lang="ts"> import { defineComponent } from 'vue'; import HelloWorld from './components/HelloWorld.vue'; export default defineComponent({ name: 'App', components: { HelloWorld } }); </script> ``` 现在,您可以运行您的Vue 3 + TypeScript项目并使用该组件了。运行以下命令启动开发服务器: ``` npm run serve ``` 这只是一个简单的示例,您可以根据自己的需求在项目使用更多的Vue组件和功能。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值