2021 vue接入天气情况api

news/2024/7/10 2:23:12 标签: vue

在这里插入图片描述

<template>
    <div>
        <h2>天气:{{weather}}</h2>
        <h3>城市:{{city}}</h3>
        <h4>温度:{{tem}}</h4>
        <h5>风向:{{winddir}}</h5>
    </div>
</template>

<script>
import axios from 'axios'
export default {
  data() {
    return {
        city:null,
        weather :null,
        tem:null,
        winddir: null
    }
  },
  async beforeMount () {
  //key去到https://dev.qweather.com/docs/api/weather/weather-now/申请
    let key = '你的key';
    let httpurl = `https://free-api.heweather.net/s6/weather/now?location=${this.$route.params.city}&key=${key}`;
    let res = await axios.get(httpurl)
    this.city = res.data.HeWeather6[0].basic.location;
    this.weather =res.data.HeWeather6[0].now.cond_txt;
    this.tem= res.data.HeWeather6[0].now.tmp;
    this.winddir =res.data.HeWeather6[0].now.wind_dir;
    console.log(res)
  }
}
</script>

vue循环动态跳转:
在这里插入图片描述


http://www.niftyadmin.cn/n/1463340.html

相关文章

python os.path.dirname(os.path.dirname(__file__))与os.path.dirname(__file__)区别

由图知&#xff0c;使用一次os.path.dirname(file)是返回当前文件的文件夹&#xff0c;使用两次则返回上层&#xff0c;三次再上层。。。。

python 关于frame或iframe嵌套内层里的switch_to.frame和switch_to.default_content方法的使用

【第一种 括号里加的是iframe标签的id或者是name,这样就能跳转到指定的iframe&#xff1b;login_frame是iframe的值】 driver.switch_to.frame(“login_frame”) 【第二种 用定位方式】 #driver.switch_to.frame(driver.find_element_by_xpath(’//*[id“login_frame”]’))…

记录c + +

思路 1、定义存储数组。 2、被减数和减数确认。由于减法可能出现负数。 3、读入数据到数组中。注意:保证被减数大于减数;倒序存放,也就是个位放在数组下标为 0 的地方。 4、从个位开始模拟竖式减法的过程,完成整个减法。 5、删除前导 0 。所谓前导零,就是出现类似这样数据…

估计的商是什么意思_搞笑段子:“我这是得了什么病啊?好害怕啊”哈哈哈哈太刺激了...

阅读本文前&#xff0c;请您先点击上面的蓝色字体&#xff0c;再点击“关注”&#xff0c;这样您就可以继续免费收到文章了。每天都有分享&#xff0c;完全是免费订阅&#xff0c;请放心关注。 注&#xff1a;本文…

c++选择排序

一、选择从大到小 int main() {int n;cin>>n;int list[n];for(int i0;i<n;i){cin>>list[i];}for(int i0;i<n;i){cout<<list[i]<<" ";}cout<<endl;for(int in-1;i>0;i--){int mini;for(int ji-1;j>0;j--){if(list[j]<l…

nodejs shell交互,使用node.js执行Shell程序并传递参数

I would like to execute an shell program who require any params with Node.jsHow can I do that ?解决方案To execute shell commands:var sys require(sys)var exec require(child_process).exec;exec(command, function (error, stdout, stderr) {});To run a program…

c++ 数组元素向左移动n次

数组元素向左移动 int n;//共几个 int a[n];cin>>n;int cishu;//移动次数int temp;for(int i0;i<n;i){cin>>a[i];}cin>>cishu;//for(int i0;i<cishu;i){//控制移动次数 tempa[0];//每次都拿第一个出来 for(int j0;j<n;j){a[j]a[j1];}a[n-1]temp;}f…

4安全框_为什么市场上越来越流行窄框推拉门

现代风格多为精英人士的家居首选&#xff0c;去繁为简的设计思路是大众业主的百搭。一方面&#xff0c;可以节约装修费用&#xff0c;另一方面&#xff0c;简约风格也符合现代年轻人的审美习惯。门窗产品中&#xff0c;简约风格系列莫过于近年来最流行的窄框推拉门。今天我们来…