React开发实时聊天招聘工具 -第二章

 2-1 介绍React开发环境

npm install -g

create-react-app xxx

npm run eject   来配置webpack

 2-2 ES6常用语法

其他

还有一些特性,虽然不在ES6的范围内,但是也被babel支持,普遍被大家接受和使用(需要安装插件)

·对象扩展符,函数绑定

·装饰器

·Async await

2-3 Express简介

var app = express()

app.get('/',function(){

   res.send('Hello world')

})

app.listen(9083,function(){console.log(`Server is running at port 9093`)})

app.use //使用模块

2-4 MongoDB

mongoose的使用:

const DB_URL = 'mongodb://localhost:27017/imooc'
mongoose.connect(DB_URL, { useNewUrlParser: true },(err)=>{
console.log('connected');
})
 
// 文档对象模型
const User = mongoose.model('user',
new mongoose.Schema({
user: { type: String, require: true },
age: { type: Number, require: true }
}))
 
 
User.create({
name: 'imooc',
age: 18
},
function (err, doc) {
if(!err) console.log(doc)
})
 
Uesr.remove({age:18},function(){...})
 
User.update({name:'xiaoming'},{'$set':{age:26}},function(){..})
 
 
User.find({name:'xiaoming'},function(){ ... })
 
User.findOne
 
 
app.get(`/data`, function (req, res) {
User.find({},function(){
res,json(doc)
})
})
 
 
 
 
 

猜你喜欢

转载自www.cnblogs.com/eret9616/p/9281824.html