A WeApp project template in TypeScript using VS Code
VS Code下基于TypeScript的微信小程序项目模板
This is a WeApp project template using TypeScript where async/await
can be used freely even targetting ES5
使用TypeScript的微信小程序项目模板 可以在目标ES5的时候随意地使用async/await
- There are some node module dependencies should be installed globally or locally:
- 全局或本地安装下列Node依赖模块:
Node Module | Command |
---|---|
TypeScript>2.1.4 | npm install -g typescript |
Typings | npm install -g typings |
TSLint | npm install -g tslint |
Gulp | npm install -g gulp |
-
After installing those modules run the command of
npm install
andtypings install
to install dev dependencies and typings dependencies then the project can be built by the commandgulp
which runs the default task in gulpfile.js -
安装完以上模块后 使用命令
npm install
和typings install
来安装开发依赖模块和Typings依赖 然后就可以通过gulp
命令编译整个项目 -
These VS Code extensions is recommeded to be installed:
-
推荐安装下列VS Code插件:
-
All files are built into a dist folder so it is the
dist
folder which will be referenced in Wexin dev tool for a WeApp instead of theproject folderor the folder ofsrc
-
所有文件都被编译到 dist 文件夹下 所以在微信开发者工具中应该引用
dist
文件夹 而不是项目文件夹或者src
文件夹
async/await
can be used freely when targetting ES5 with the ES6-promise polyfill imported- 引用ES6-promise polyfill后可以在指向ES5时随意地使用
async/await
- The sample code about
async/await
can be found in app.ts and http-client.ts async/await
相关的示例代码在app.ts和http-client.ts文件中- The first commented line should be reserved to import the ES6-promise polyfill after TypeScript compilation and this line of code shoud be added with adjusting the relative path of
es6-promise.min.js
to the file whereasync/await
is used - 文件中的第一行注释是用来在TypeScript编译之后引入ES6-promise polyfill的 所以应该被保留 并且 所有用到
async/await
的文件都应该在调整es6-promise.min.js
文件的相对路径后添加这行代码
// var Promise = require('./utils/es6-promise.min').Promise;
2016.12.12