axios 安装
cnpm install axios --save
App.vue文件
<script>
import axios from 'axios'
export default {
name: 'App',
setup () {
let api = 'https://api.apiopen.top/api/getHaoKanVideo?page=0&size=2'
// 写法一:fetch
// fetch(api).then(res => res.json()).then(result => {
// store.setList(result,'请求结果')
// })
// 写法二:axios
axios.get(api).then(res => {
console.log(res, '请求结果 ')
})
}
}
</script>
最后
以上就是寂寞鲜花最近收集整理的关于Vue——vue3实现前后端交互fetch、axios写法的全部内容,更多相关Vue——vue3实现前后端交互fetch、axios写法内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复