Project: Vue2, Vuex, Typescript, Stylus, Eslint, Tslint, axios
A Vue.js + TypeScript project
# install dependencies
npm install
# serve with hot reload at localhost:8080
npm run dev
# build for production with minification
npm run build
# build for production and view the bundle analyzer report
npm run build --report
# run unit tests
npm run unit
# run e2e tests
npm run e2e
# run all tests
npm test
For a detailed explanation on how things work, check out the guide and docs for vue-loader.
vue init webpack vue-typescript
sudo yarn (chromedriver: Command failed.)
有一个安装错误,不影响项目启动,后续再深入解决
如果需要权限,添加 sudo 再执行以下命令
yarn add vue-class-component vue-property-decorator
yarn add ts-loader typescript tslint tslint-loader tslint-config-airbnb-base -D
找到entry.app 将main.js 改成 main.ts, 顺便把项目文件中的main.js也改成main.ts, 里面内容保持不变
resolve.extensions 里面加上.ts 后缀 (是为了之后引入.ts的时候不写后缀)
找到module.rules 添加webpack对.ts的解析
添加 tsconfig.json, tslint.json (使用 tslint-config-airbnb-base 插件)
添加 vue-shim.d.ts 文件
告诉 TypeScript *.vue 后缀的文件可以交给 vue 模块来处理