tp 天气Vue参考
<!DOCTYPE html>
<html>
<head>
<title>Bootstrap 实例</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/css/bootstrap.min.css">
<script src="https://cdn.staticfile.org/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdn.staticfile.org/popper.js/1.15.0/umd/popper.min.js"></script>
<script src="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/js/bootstrap.min.js"></script>
<script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script> </head>
<style>
.container{
width: 80%;
margin: 0 auto;
border:1px solid #cccccc;
border-radius: 10px;
padding: 40px;
}
table{
margin-top: 40px;
}
</style>
<body> <div class="container">
<form class="form-inline">
<label for="city">请选择城市:</label>
<input type="text" class="form-control" id="city" placeholder="请选择城市" v-model="city">
<button type="button" class="btn btn-primary" v-on:click="search">查询</button>
</form>
<table class="table table-bordered">
<thead>
<tr>
<th>城市</th>
<th>日期</th>
<th>温度</th>
<th>天气情况</th>
<th>风向</th>
</tr>
</thead>
<tbody>
<tr v-for="item in info">
<td>{{ city }}</td>
<td>{{ item.date }}</td>
<td>{{ item.temperature }}</td>
<td>{{ item.weather }}</td>
<td>{{ item.direct }}</td>
</tr>
</tbody>
</table>
</div>
</body>
<script>
new Vue({
el: '.container',
data () {
return {
info: null,
city: null
}
},
// mounted () {
//
// },
methods:{
search:function(){
_this = this;
axios
.get('http://www.1809A.com/api/Index/index/city/'+_this.city)
.then(function (response) {
_this.info = response.data.result.future;
_this.city = response.data.result.city;
})
.catch(function (error) { // 请求失败处理
console.log(error);
});
}
}
})
</script>
</html>
api模块index控制器kuaidi方法 public function index()
{
// 查询天气预报
$city = input("city");
// 确定接口地址:
$url = "http://apis.juhe.cn/simpleWeather/query";
// 确定参数
$param = ['city'=>$city,'key'=>'7808686de93c14aae043ee1b8eb9916c'];
// 调用函数执行
$result = curl_request($url,true,$param);
// 判断结果
if(!$result){
echo "查询失败";
die;
}
// 成功
return $result;
}

tp 天气Vue参考的更多相关文章
- vue参考
https://github.com/taylorchen709/vue-admin http://element-cn.eleme.io/#/zh-CN/component/layout https ...
- 新手创建Vue项目
======================安装vue=============================(参考网址:http://www.bubuko.com/infodetail-21320 ...
- vue源码逐行注释分析+40多m的vue源码程序流程图思维导图 (diff部分待后续更新)
vue源码业余时间差不多看了一年,以前在网上找帖子,发现很多帖子很零散,都是一部分一部分说,断章的很多,所以自己下定决定一行行看,经过自己坚持与努力,现在基本看完了,差ddf那部分,因为考虑到自己要换 ...
- vue eslint 代码自动格式化
vue-cli 代码风格为 JavaScript Standard Style 代码检查规范严格,一不小心就无法运行,使用eslint的autoFixOnSave可以在保存代码的时候自动格式化代码 V ...
- vue之mapMutaions的使用 && vuex中 action 用法示例 && api.js的使用
vue之mapMutations的使用 我们通过Mutation来改变store中的state,方法往往是在子组件中使用 this.$store.commit(); 来实现,但是这样的缺点是不容易查看 ...
- vue理解$nextTick
首先要明确: Vue 实现响应式并不是数据发生变化之后 DOM 立即变化,而是按一定的策略进行 DOM 的更新. $nextTick 是在下次 DOM 更新循环结束之后执行延迟回调,在修改数据之后使用 ...
- vue系列之vue cli 3引入ts
插件 Vue2.5+ Typescript 引入全面指南 vue-class-component强化 Vue 组件,使用 TypeScript/装饰器 增强 Vue 组件 vue-property-d ...
- angular里使用vue/vue组件怎么在angular里用
欢迎加入前端交流群交流知识&&获取视频资料:749539640 如何在angularjs(1)中使用vue参考: https://medium.com/@graphicbeacon/h ...
- Vue框架Element UI教程-axios请求数据
Element UI手册:https://cloud.tencent.com/developer/doc/1270 中文文档:http://element-cn.eleme.io/#/zh-CN gi ...
随机推荐
- Java--这张线程瓜图保熟,不进来看看?这瓜要是不熟它就Dead掉了
先来看一下线程这张图线程的几种运行状态之间运行流程: 看不懂没关系,慢慢来学习,往下学习来继续了解一下~ 什么是线程? 线程是进程的一部分,是程序执行中的一条执行路线: 进程就是指程序在其自身地址空间 ...
- git删除误传的.idea文件
问题: 提交项目的时候忘记添加.gitignore文件,误上传了文件(如.idea)如何解决?如何删除Gitee地址上项目的.idea文件?(本文以.idea文件夹举例) 拉取项目 拉取项目 git ...
- 连接mysql出现“Unable to load authentication plugin 'caching_sha2_password”错误
这是mysql 8.0版本才出现的问题,原因是mysql 8.0 默认使用 caching_sha2_password 身份验证机制 -- 从原来的 mysql_native_password 更改为 ...
- redis清缓存
先查询当前redis的服务是否已经启动 ps -ef|grep redis [root@guanbin-k8s-master ~]# ps -ef|grep redis redis 1557 1 0 ...
- 淘大大出了composer镜像 -- 给力
composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
- linux 下 ifcfg-eth0 配置
网络接口配置文件[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0# Intel Corporation 82545EM ...
- 搭建golang开发环境(1.14之后版本)
Go语言1.14版本之后推荐使用go modules管理依赖,也不再需要把代码写在GOPATH目录下. 下载地址 Go官网下载地址:https://golang.org/dl/ Go官方镜像站(推荐) ...
- java+selenium脚本编写规范
2. 源文件规范 2.1 文件名 源文件以最顶层的类名来命名,大小写敏感,文件扩展名为.java 2.2 文件编码 UTF-8 源文件要求编码格式为UTF-8 2.3 源文件结 ...
- 基于XC7A100T的PCIe千兆电口以太网收发卡
一.板卡概述 本板卡采用Xilinx公司的Artix7系列的XC7A100T-2FGG484 芯片作为主处理器.包含双路千兆电口网络,双组DDR,PCIeX1 V1.1接口,板卡设计满足工业级要求. ...
- Note -「Lagrange 插值」学习笔记
目录 问题引入 思考 Lagrange 插值法 插值过程 代码实现 实际应用 「洛谷 P4781」「模板」拉格朗日插值 「洛谷 P4463」calc 题意简述 数据规模 Solution Step 1 ...