Skip to content

Commit 41a9b85

Browse files
authored
Update README.md
1 parent 69f28e6 commit 41a9b85

File tree

1 file changed

+70
-6
lines changed

1 file changed

+70
-6
lines changed

README.md

+70-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,72 @@
1-
### npm install redux --save 安装第三方库redux
2-
### npm run eject 弹出配置文件,可以自定义配置webpack
3-
### 扩展package。json里的script的script字段,扩展npm run命令
1+
### 一、
2+
1、npm install -g create-react-app
3+
2、新建一个应用 create-react-app test(test为项目名)
4+
3、安装第三方库 npm i redux --save
5+
4、自定义配置 npm run eject 弹出配置文件,可以自定义配置webpack
6+
5、扩展package.json里的script字段,扩展npm run命令
7+
8+
### 二、
9+
安装node.js,express 在根文件和src同级新建server文件夹和server.js文件
10+
由于node里没有原生支持import 需要require依赖
11+
12+
const express = require('express')
13+
// 新建app
14+
const app = express()
15+
16+
app.get('/', function(req, res){
17+
res.send('<h1>hello world1</h1>')
18+
})
19+
20+
app.get('/data', function(req, res){
21+
res.json({
22+
name: 'yyh',
23+
type: 'IT'
24+
})
25+
})
26+
27+
app.listen(9090, function(){
28+
console.log('node start at 9090')
29+
})
30+
31+
初始node
32+
33+
### 监听路由和响应内容,使用nodemon自动重启npm install -g nodemon
34+
### 安装mongodb, mongoose npm install mongoose --save
35+
### mongodb是一个基于分布式文件存储的数据库
36+
37+
38+
const mongoose = require('mongoose')
39+
// 链接mongo
40+
const DB_URL = 'mongodb://127.0.0.1:27017/imooc'
41+
mongoose.connect(DB_URL, {useNewUrlParser:true})
42+
43+
mongoose基础使用
44+
45+
connerct链接数据库
46+
定义文档模型,schema和model新建模型
47+
48+
mongoose 文档类型 string,number等
49+
增删改查 create, remoce ,update, find / findOne
50+
51+
// User.create({
52+
// name: 'imooc',
53+
// age: 18
54+
// }, function(err, doc) {
55+
// if (!err) {
56+
// console.log(doc)
57+
// } else {
58+
// console.log(err)
59+
// }
60+
// })
61+
62+
63+
User.find({}, function(err, doc) {
64+
res.json(doc)
65+
})
66+
67+
68+
User.update({'user': 'xiaoming'}, {'$set': {age: 26}}, function(err, doc) {
69+
console.log(doc)
70+
})
471

5-
### 安装 antd --save
6-
### babel-plugin-import --save 按需加载组件代码和样式
772

8-
### nodemon server.js 启动服务

0 commit comments

Comments
 (0)