Open zhouyun163 opened 6 years ago
npm config set registry https://registry.npm.taobao.org
https://upload-images.jianshu.io/upload_images/16777-673d7b071ce2e527.png
angular5快速创建工程的命令
ng new my-app cd my-app ng serve --open
参考:https://www.angular.cn/guide/quickstart
执行上述命令之后可以通过 http://localhost:4200/ 访问启动的服务器 但是却不能使用ip地址访问
在ng server后面增加配置项--host 0.0.0.0之后,就可以通过类似 http://192.168.1.103:4200/ 这样的地址来反问了,这样你就可以通过你的手机连接到同一个局域网之后测试你的针对手机开发的应用了
ng serve --host 0.0.0.0
参考:https://github.com/angular/angular-cli/issues/2375#issuecomment-250008380
ng build --aot ng server --aot
参考:https://angular.io/guide/aot-compiler
ng build --prod
参考:https://stackoverflow.com/questions/38932193/angular-2-4-5-ahead-of-time-compilation-how-to
在新建目录中,初始化npm工程
npm init -y
全局安装webpack
npm install -g webpack
安装typescript和ts-loader
npm install --save-dev typescript ts-loader
新建tsconfig.js文件。
{
"compilerOptions": {
"outDir": "./dist",
"sourceMap": true,
"noImplicitAny": true,
"module": "es6",
"target": "es2015",
"allowJs": false
}
}
新建webpack.config.js文件
const path = require("path");
module.exports = {
entry: {
index: "./src/index.ts"
},
devtool: "inline-source-map",
module: {
rules: [
{
test: /\.tsx?$/,
use: "ts-loader",
exclude: /node_modules/
}
]
},
resolve: {
extensions: [".ts", ".tsx", ".js"]
},
output: {
filename: '[name].js',
path: path.resolve(__dirname, 'dist')
}
};
新建文件/src/index.ts
console.log("test");
执行webpack命令
webpack
确认结果:确认是否新生成了如下目录结构和文件
|---dist
|---index.js
morgan: HTTP request logger middleware for node.js. https://www.npmjs.com/package/morgan
express-handlebars: A Handlebars view engine for Express which doesn't suck. https://www.npmjs.com/package/express-handlebars
body-parser: Parse incoming request bodies in a middleware before your handlers https://www.npmjs.com/package/body-parser
cookie-parser: Parse Cookie header and populate req.cookies with an object keyed by the cookie names. https://www.npmjs.com/package/cookie-parser
安装@types/node
npm install @types/node --save
参考:http://www.guanggua.com/question/41687644-cannot-find-name-require-in-typescript.html
在mac系统下不认识code命令
bogon:test-snippets zhouyun$ code . -bash: code: command not found
After installation, launch VS Code. Now open the Command Palette (⇧⌘P) and type shell command to find the Shell Command: Install 'code' command in PATH command.
"files.associations": {
"*.mysuffix":"html"
}
在vscode中做如上设置之后,以mysuffix后缀打开的文件,都会被使用html语言编辑器打开,同时也就有了html编辑器的联想着色等能力。
示例代码,画了1个三角形 参考
<svg width="100%" height="100%" style="overflow: visible;" version="1.1" xmlns="http://www.w3.org/2000/svg">
<path d="M250 150 L150 350 L350 350 Z" />
</svg>
$event.stopPropagation()
<button class="delete" (click)="delete(hero); $event.stopPropagation()">x</button>
记录本年度学习到的内容or解决的问题