如何将打字稿添加到现有的 vue3 项目中?
How to add typescript to existing vue3 project?
我有以下 package.json
文件:
{
"name": "view",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"@vue-leaflet/vue-leaflet": "^0.6.1",
"autoprefixer": "^10.3.1",
"core-js": "^3.6.5",
"gpxparser": "^3.0.8",
"leaflet": "^1.7.1",
"postcss": "^8.3.6",
"tailwindcss": "^2.2.7",
"typescript": "^4.3.5",
"vue": "^3.0.0",
"vue-router": "^4.0.0-0",
"vue3-openlayers": "^0.1.38",
"vuex": "^4.0.2"
},
"devDependencies": {
"@vue/cli-plugin-babel": "^5.0.0-beta.3",
"@vue/cli-plugin-eslint": "^5.0.0-beta.3",
"@vue/cli-plugin-router": "^5.0.0-beta.3",
"@vue/cli-service": "^5.0.0-beta.3",
"@vue/compiler-sfc": "^3.0.0",
"@vue/eslint-config-prettier": "^6.0.0",
"babel-eslint": "^10.1.0",
"eslint": "^7.32.0",
"eslint-plugin-prettier": "^3.3.1",
"eslint-plugin-vue": "^7.0.0",
"prettier": "^2.2.1",
"sass": "^1.26.5",
"sass-loader": "^8.0.2"
}
}
如何将 typescript 添加到此 vue3 项目中?
我使用 yarn 作为包管理器,当我尝试通过
yarn add typescript
,它确实将它安装到项目中,但我无法在我的组件中使用 TypeScript。
运行 vue add typescript
在命令行上
我有以下 package.json
文件:
{
"name": "view",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"@vue-leaflet/vue-leaflet": "^0.6.1",
"autoprefixer": "^10.3.1",
"core-js": "^3.6.5",
"gpxparser": "^3.0.8",
"leaflet": "^1.7.1",
"postcss": "^8.3.6",
"tailwindcss": "^2.2.7",
"typescript": "^4.3.5",
"vue": "^3.0.0",
"vue-router": "^4.0.0-0",
"vue3-openlayers": "^0.1.38",
"vuex": "^4.0.2"
},
"devDependencies": {
"@vue/cli-plugin-babel": "^5.0.0-beta.3",
"@vue/cli-plugin-eslint": "^5.0.0-beta.3",
"@vue/cli-plugin-router": "^5.0.0-beta.3",
"@vue/cli-service": "^5.0.0-beta.3",
"@vue/compiler-sfc": "^3.0.0",
"@vue/eslint-config-prettier": "^6.0.0",
"babel-eslint": "^10.1.0",
"eslint": "^7.32.0",
"eslint-plugin-prettier": "^3.3.1",
"eslint-plugin-vue": "^7.0.0",
"prettier": "^2.2.1",
"sass": "^1.26.5",
"sass-loader": "^8.0.2"
}
}
如何将 typescript 添加到此 vue3 项目中?
我使用 yarn 作为包管理器,当我尝试通过
yarn add typescript
,它确实将它安装到项目中,但我无法在我的组件中使用 TypeScript。
运行 vue add typescript
在命令行上