日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

vue实现查询多条记录_vue.js 实现天气查询

發布時間:2025/3/11 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 vue实现查询多条记录_vue.js 实现天气查询 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

效果預覽:http://songothao.gitee.io/weather_query_based_on_vuejs/

項目已上傳碼云:叁貳壹/vuejs實現天氣查詢

知乎視頻?www.zhihu.com

一、使用 axios + vue.js:

  • axios-get請求:
  • axios.get(地址?key=value&key2=value2).then(function(response){} ).catch( function(err){} );

    2. axios-post 請求:

    axios.post(地址, {key:value, key2:value2}).then(function(response){} ).catch( function(err){} );

    3. 引入 axios

    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>

    二、天氣的接口 http://wthrcdn.etouch.cn/weather_mini

    三、代碼實現

    main.js

    var app = new Vue({el: "#app",data: {city: '',forecast: []},methods: {search: function() {var that = this;axios.get(`http://wthrcdn.etouch.cn/weather_mini?city=${this.city}`).then((res) => {that.forecast = res.data.data.forecast;}).catch((err) => {console.log(err);})},changeCity: function(city) {this.city = city;this.search();}} })

    index.html

    <!DOCTYPE html> <html lang="zh"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>查詢天氣</title><link rel="stylesheet" href="./css/reset.css"><link rel="stylesheet" href="./css/index.css"><script src="https://unpkg.com/axios/dist/axios.min.js"></script><script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script> </head><body><div class="wrap" id="app"><header class="header"><h1>小朋友查天氣</h1></header><section class="main"><section class="search"><input type="text" placeholder="請輸入查詢的城市" v-model='city' @keyup.enter='search'><span class="btn" @click="search">搜索</span></section><section class="common-use"><a href="javascript:;" @click="changeCity('北京')">北京</a><a href="javascript:;" @click="changeCity('上海')">上海</a><a href="javascript:;" @click="changeCity('廣州')">廣州</a><a href="javascript:;" @click="changeCity('深圳')">深圳</a></section><section class="weather"><ul><li v-for='item in forecast'><div><h1>{{item.type}}</h1><p>{{item.low}} ~ {{item.high}}</p><p>{{item.date}}</p></div></li></ul></section></section></div><script src="./js/main.js"></script> </body></html>

    CSDN:https://blog.csdn.net/weixin_43148062

    簡書:https://www.jianshu.com/u/45339cbb7573

    總結

    以上是生活随笔為你收集整理的vue实现查询多条记录_vue.js 实现天气查询的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。