国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 語言 > JavaScript > 正文

使用VueCli3+TypeScript+Vuex一步步構建todoList的方法

2024-05-06 15:36:40
字體:
來源:轉載
供稿:網友

前言

Vue3.x 即將來襲,使用 TypeScirpt 重構,TypeScript 將成為 vue 社區的標配,出于一名程序員的焦慮,決定現在 Vue2.6.x 踩一波坑。

vue 官方文檔已經簡略地對 typescript 的支持進行了介紹,我們使用 Vue Cli3 直接生成項目

創建項目

❓為什么使用 Vue Cli3 構建項目

官方維護,后續升級減少兼容性問題

使用以下配置進行項目的生成:

Babel 對 Ts 進行轉譯 TSLint 對 TS 代碼進行規范,后續會使用 prettier 對項目進行編碼的統一 默認安裝 Vuex 和 Router , Router 使用  history 模式 使用 Jest 進行單元測試
╭─~/otherEWokspace╰─➤ vue create ts-vuex-demoVue CLI v3.6.3┌───────────────────────────┐│ Update available: 3.9.3 │└───────────────────────────┘? Please pick a preset: Manually select features? Check the features needed for your project: Babel, TS, Router, Vuex, CSS Pre-processors, Linter, Unit? Use class-style component syntax? Yes? Use Babel alongside TypeScript for auto-detected polyfills? Yes? Use history mode for router? (Requires proper server setup for index fallback in production) Yes? Pick a CSS pre-processor (PostCSS, Autoprefixer and CSS Modules are supported by default): Sass/SCSS (with node-sass)? Pick a linter / formatter config: TSLint? Pick additional lint features: (Press <space> to select, <a> to toggle all, <i> to invert selection)Lint on save? Pick a unit testing solution: Jest? Where do you prefer placing config for Babel, PostCSS, ESLint, etc.? In dedicated config files? Save this as a preset for future projects? Yes? Save preset as: ts-vue-demo

看一下新項目的層級目錄

╭─~/otherEWokspace/ts-vuex-demo ‹master›╰─➤ tree -L 2 -I node_modules.├── README.md├── babel.config.js├── jest.config.js├── package-lock.json├── package.json├── postcss.config.js├── public│  ├── favicon.ico│  └── index.html├── src│  ├── App.vue│  ├── assets│  ├── components│  ├── main.ts│  ├── router.ts│  ├── shims-tsx.d.ts│  ├── shims-vue.d.ts│  ├── store.ts│  └── views├── tests│  └── unit├── tsconfig.json└── tslint.json

tsconfig.json

對 lib 、 target 、 module 進行解釋

{ "compilerOptions": {  "target": "esnext",  "module": "esnext",  "strict": true,  "jsx": "preserve", // 開啟對 jsx 的支持  "importHelpers": true,  "moduleResolution": "node",  "experimentalDecorators": true,  "esModuleInterop": true,  "allowSyntheticDefaultImports": true,  "sourceMap": true,  "baseUrl": ".",  "types": [   "webpack-env",   "jest"  ],  "paths": {   "@/*": [    "src/*"   ]  },  "lib": [   "esnext",   "dom",   "dom.iterable",   "scripthost"  ] }, "include": [  "src/**/*.ts",  "src/**/*.tsx",  "src/**/*.vue",  "tests/**/*.ts",  "tests/**/*.tsx" ], "exclude": [  "node_modules" ]}            
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表

圖片精選

主站蜘蛛池模板: 商洛市| 错那县| 淮阳县| 潼南县| 大足县| 汉中市| 霍山县| 张北县| 新兴县| 雷州市| 平陆县| 许昌市| 京山县| 高碑店市| 岑巩县| 建瓯市| 江门市| 开化县| 柘荣县| 缙云县| 登封市| 温宿县| 神池县| 西畴县| 六枝特区| 京山县| 库尔勒市| 荆州市| 乌拉特前旗| 皮山县| 九台市| 大竹县| 张家港市| 德格县| 沐川县| 迁西县| 岢岚县| 普安县| 舒城县| 咸阳市| 绥宁县|