const 变量不变 let 变量可变
箭头函数,支持默认设置参数
字符模板,不再使用+链接字符串
解析结构
简写,当属性和值相同
类
模块
接口定义可以是变量,函数,类
var m=1
export fn
export default默认方法或变量,只能一个,不能用花括号
import {m} from ‘m’;
ajax请求
fetch(“/hi”,{method:”GET”})
.then(res=>res.json())
.then(res=>{
console.log(res.name)
})
.catch(e=>alert(‘出错了’+e))
post标准提交
fetch(“/hi”,{method:”POST”,body: ‘name=中国’,mode:”cors”,headers: {
“Content-type”: “application/x-www-form-urlencoded; charset=UTF-8”,
},})
.then(res=>res.json())
.then(res=>{
console.log(res.name)
})
.catch(e=>alert(‘出错了’+e))
//post json提交 默认
fetch(“/hi”,{method:”POST”,body: JSON.stringify({“name”:”中国”}),mode:”cors”,headers: {
//“Content-type”:”application/json;charset=utf-8”,
},})
.then(res=>res.json())
.then(res=>{
console.log(res.name)
})
.catch(e=>alert(‘出错了’+e))
更新时间:2024-12-05 13:26