将load中的fetch代码改写为axios。export default { name: "Calendar", data() { return { value: new Date(), arr: [] } }, created(){ this.load() }, methods: { load() { fetch("http://localhost:8013/api/calendar").then(res => res.json()).then(res => {this.arr = res}) }, handleClick(date) { alert(date) } } } </script>
时间: 2023-03-28 09:02:37 浏览: 95
可以这样改写:
import axios from 'axios';
export default {
name: "Calendar",
data() {
return {
value: new Date(),
arr: []
}
},
created(){
this.load()
},
methods: {
load() {
axios.get("http://localhost:8013/api/calendar").then(res => {this.arr = res.data})
},
handleClick(date) {
alert(date)
}
}
} </script>
阅读全文
相关推荐
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![md](https://img-home.csdnimg.cn/images/20250102104920.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20241231044930.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)