<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<script src="https://cdn.jsdelivr.net/npm/vue@2"></script>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<div id="app">
<input type="button" value="点我显示笑话" @click="getJokes"/>
<p>{{ joke }}</p>
</div>
<script>
var app = new Vue({
el:"#app",
data:{
joke:"一个笑话"
},
methods:{
getJokes:function(){
var that = this;
axios.get("https://autumnfish.cn/api/joke").then
(function(response){
that.joke = response.data;
},function(err){
console.log(err);
})
}
}
})
</script>
</body>
</html>
axios+vue 网页请求
最新推荐文章于 2023-03-31 20:23:52 发布