【发布时间】:2020-06-07 03:24:25
【问题描述】:
我是 vuejs 新手,我正在学习本教程 (https://www.youtube.com/watch?v=Wy9q22isx3U&t=3492s)。 当我尝试发出发布请求时,出现此错误(已被 CORS 策略阻止:对预检请求的响应未通过访问控制检查:请求的资源上不存在“Access-Control-Allow-Origin”标头。 ) 我可以 console.log(res.data) 但我不能把它放在 todos[] 数组中。
addtodo(newTodo){
const {title,completed} = newTodo;
axios.post('https://jsonplaceholder.typicode.com/todos',{
title,
completed
})
.then(res => {
this.todos = this.todos.push[res.data];
//console.log(res.data);
})
.catch(err => console.log(err));
}
【问题讨论】: