- 导入Vue文件和axios文件
-
<script src="js/vue.min.js"></script>
-
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
代码部分:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<script src="js/vue.min.js"></script>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
</head>
<body>
<!-- 被vm 实例所控制的区域 -->
<div id="app">
<button @click="getJoke">获取笑话</button>
<input type="text" placeholder="请输入要查询的城市名~" v-model="city">
<button @click="getWeather">天气查询</button><br/>
<a href="javascript:void(0)" @click="changeDataToGetWeather('北京')">北京</a> <a href="javascript:void(0)" @click