一.今日学习内容 1. 随机数 Math.floor(Math.random() * (max - min + 1)) + min; 2.axios两种写法 axios.get('').then(res=>{}) axios.post('').then(res=>{}) 3.axios对象的写法 Get: axios({ url: 't', method: 'get', // data:, // params:, }).then(res => { }) axios({ url: '', method: 'get', params: { id: id }, }).then(res => { console.log(res.data.data); }) post axios({ url: '', method: 'post', }).then(res => { console.log(res.data.data); }) axios({ url: '', method: 'post', data: { id: 463 }, }).then(res => { console.log(res.data.data); }) 4.图片上传 核心方法:FormData(); let fd = new FormData(); 5.跨域 协议,域名,端口,任何一个不相同就是跨域 同源协议:协议,域名,端口,三个都相同,不相同就是跨域 浏览器有同源政策,会阻止ajax跨域访问 同源策略是一种约定,是浏览器的一种安全功能 node.js服务端--自己写接口自己调用--express 解决跨域问题 jsonp script--src 服务端代理 cors跨域资源共享 vue--proxy:配置跨域相关设置
|