1 <!DOCTYPE html>
2 <html >
3 <head>
4 <meta charset="UTF-8">
5 <title>Title</title>
6 <script src="./vue.min.js"></script>
7 <script src="./axios.min.js"></script>
8 </head>
9 <body>
10
11 <div >
12 <input type="button" value="获取笑话" @click="getJoke">
13 <p>
14 {{msg}}
15 </p>
16 </div>
17 <script>
18 var vm = new Vue({
19 el:"#app",
20 data:{
21 msg:"hello world",
22 },
23 methods:{
24 getJoke(){
25 //axios.post('https://xxxxxx',{"usename":"小明"})
26 axios.get("https://utumnfish.cn/api/joke")
27 .then((response)=>{
28 this.msg=response.data;
29 })
30 .catch((err)=>{
31 this.msg=err.message;
32 })
33 },
34
35 }
36 })
37 </script>
38 </body>
39 </html>