博主首页

vue3引入ts以及js文件使用案例

ts:先确保项目正确集成TypeScript

添加tsconfig.json文件

{
  "compilerOptions": {
    "target": "esnext",
    "module": "esnext",
    "strict": true,
    "jsx": "preserve",
    "importHelpers": true,
    "moduleResolution": "node",
    "experimentalDecorators": true,
    "skipLibCheck": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "sourceMap": true,
    "baseUrl": ".",
    "types": [
      "webpack-env"
    ],
    "paths": {
      "@/*": [
        "src/*"
      ]
    }
  },
  "include": [
    "src/**/*.ts",
    "src/**/*.tsx",
    "src/**/*.vue",
    "tests/**/*.ts",
    "tests/**/*.tsx"
  ],
  "exclude": [
    "node_modules"
  ]
}

编写一个用于测试的ts文件

就定义了一个静态方法,

 然后导入使用

 

js文件使用不做过多说明  ,截图如下

 

posted @ 2025-01-08 14:29  笑~笑  阅读(249)  评论(0)    收藏  举报