vue天气查询
天气查询包括回车查询和点击查询两种功能
回车查询
1.按下回车(v-on+.enter)
2.查询数据(axios+接口+v-model)
3.渲染数据(v-for+arr)
点击查询
1.点击城市查询(v-on+自定义参数)
2.查询数据(this.)
3.渲染数据(this.)
<template>
<div id="app">
<div>
<div id="one">
<input type="text" v-model="city" placeholder="请输入需要查询城市名" @keyup.enter="search" /><button @click="search">搜索</button>
</div>
<div id="two">
<a href="javascript:;" @click="change('北京')">北京</a>
<a href="javascript:;" @click="change('上海')">上海</a>
<a href="javascript:;" @click="change('广州')">广州</a>
<a href="javascript:;" @click="change('深圳')">深圳</a>
</div>
<ul id="three">
<li v-for="value in wList">
<div>
<span>{{value.type}}</span>
</div>
<div>
<b>{{value.low}}</b>
~
<b>{{value.high}}</b>
</div>
<div>
<span>{{value.date}}</span>
</div>
</li>
</ul>
</div>
</div>
</template> <script>
export default {
name: "App",
data: () => {
return {
city: "",
wList: []
};
},
methods: {
search: function() {
console.log(this.city);
var that = this;
this.$axios({
url: "http://wthrcdn.etouch.cn/weather_mini?city=" + this.city,
methods: "get"
})
.then(function(response) {
// console.log(response.data.data.forecast)
that.wList = response.data.data.forecast;
})
.catch(function(err) {});
},
change: function(city) {
this.city = city;
// methods中定义的方法内部,可以通过this关键字调用其他的方法
this.search();
}
},
created: function() {}
};
</script> <style>
#app {
font-family: "Avenir", Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
} ul,
li {
list-style: none;
padding: 0;
}
#app>div{
width: 900px;
margin: 0 auto;
}
#one{
text-align: left;
margin-left: 150px;
}
#one input{
width: 400px;
height: 30px;
border: 2px solid #ccc;
}
#one button{
width: 80px;
height: 35px;
background-color: #0af;
border: 0;
}
#two{
text-align: left;
margin-bottom: 40px;
margin-left: 155px;
margin-top: 5px;
}
#two a{
color: rgb(102, 99, 99);
text-decoration: none;
font-size: 14px;
}
#three li{
float: left;
border-right: 2px solid #ccc;
padding: 6px;
}
#three li:first-child{
padding-left:0;
}
#three li:last-child{
border: 0
}
li div{
margin: 10px 0;
}
li div:first-child span{
font-size: 20px;
color: #ef7000;
font-weight: bold;
}
li div:first-child{
margin-top: 0
}
li div:last-child span{
font-size: 14px;
color: #999;
}
li div:last-child {
margin-bottom: 0
}
</style>
vue天气查询的更多相关文章
- 基于node的cmd迷你天气查询工具
1.前几天网上看到的,于是自己小改了一下,更换了天气查询的接口,当作练习一下node. 2.收获挺大的,捣鼓了一天,终于学会了发布npm包. 3.接下来,就介绍一下这个 mini-tianqi 的主要 ...
- H5天气查询demo(二)
最近刚好有空,学长帮忙让做个毕设,于是我提到了那个基于H5地理位置实现天气查询的方法,学长听了也觉得不错,于是就这个主题,扩展了一下,做了一个航班管理查询系统,为上次博客中提到的利用H5 api中的经 ...
- C#调用天气查询服务
先引入天气查询服务 1.有点引用导入服务引用 //实例化 web引用名.WeatherWebService cn = new web引用名.WeatherWebService() ...
- 【转】根据中国气象局提供的API接口实现天气查询
本文转载自 老三 的 三叶草 中国气象局提供了三个天气查询的API接口: [1]http://www.weather.com.cn/data/sk/101190101.html [2]http://w ...
- 天气查询SDK
简介: 这是一个用于查询天气的SDK,在很多时候,尤其是对接多而小功能公众账号的时候,天气查询比较使用,此SDK就是这样的用途,使用的是中国天气网的API,已经集成了网上最靠谱的方式来实现,包括里面的 ...
- Android 身份证号码查询、手机号码查询、天气查询
1.基本信息 身份证号码查询:http://apistore.baidu.com/apiworks/servicedetail/113.html 手机号码:http://apistore.baidu. ...
- 根据中国气象局提供的API接口实现天气查询
中国气象局提供了三个天气查询的API接口: [1]http://www.weather.com.cn/data/sk/101190101.html [2]http://www.weather.com. ...
- 05_天气查询_JAX-WS方式_客户端
[客户端特点] 支持面向对象开发. 客户端功能调用webService,首先得知道WebService的地址. 一般情况下,只要知道了wsdl的地址,就可以知道WebService的地址. 我们上一篇 ...
- 03_天气查询_socket方式模拟_多线程方式
[简述] 要重视Socket开发,企业后台服务特长使用Socket. 1.服务端要有可持续运行能力,保证线程一致在运行 2.并发处理能力,使用多线程 [工程截图] [WeatherRunner.jav ...
随机推荐
- 题解【洛谷P1083】[NOIP2012]借教室
题面 二分到哪一个申请人要修改订单,可以差分\(+\)前缀和达到\(\Theta(n)\)的\(\text{check}\). 具体细节见代码. #include <bits/stdc++.h& ...
- 微信小程序自定义顶部导航
注释:自定义导航需要自备相应图片 一.设置自定义顶部导航 Navigation是小程序的顶部导航组件,当页面配置navigationStyle设置为custom的时候可以使用此组件替代原生导航栏. 1 ...
- [POI2006] SZK-Schools - 费用流
差不多就是个二分图带权匹配?(我还是敲费用流吧) 每个点向着自己能到的学校连边,费用按题意设定 跑最小费用最大流即可 #include <bits/stdc++.h> using name ...
- jdk 1.8.0_131 Class JavaLaunchHelper is implemented
错误提示:objc[49447]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jd ...
- linux上部署springboot应用的脚本
#!/bin/bash #getProcessId then kill pids=$(ps -ef | grep flashsale| awk '{print $2}') for pid in $pi ...
- centos7下自动备份mysql数据库
环境:centos7 .mysql5.7 第一步:创建自动备份脚本文件 mkdir backup cd backup touch backup.sh 第二步:在备份脚本文件中写入备份脚本 vim ba ...
- Windwos查看本地局域网内所有的ip方法
Windows平台ping测试局域网所有在用IP .打开cmd命令窗口 .输入命令:,,) DO ping -w -n .%i //这个是自己局域网的ip地址前三位 查看自己ip信息的命令是ipcon ...
- Go源码文件与命令
Go源码文件 文件类型 命令源码文件 : 声明自己属于main包且包含main函数的源码文件,一个包里边不要有多个命令源码文件,虽然用go install ,go run单独执行命令源码文件没有问题, ...
- OpenTLD相关资料
这是一位来自奥地利的博士生的博客 他的介绍如下: I am a PhD student at the Safety and Security Department of the Austrian In ...
- LED Holiday Light - Holiday Lighting Maintenance Guide
If you are experiencing problems with LED holiday lighting, the following guides will provide advice ...