提供されたデータの取得インタフェースを実現VUE

<!DOCTYPE HTML> 
<HTML LANG = "EN"> 
<HEAD> 
    <メタ文字コード= "UTF-8"> 
    <タイトル>タイトル</ TITLE> 
    <スクリプトSRC = "JS / vue.js"> </ SCRIPT> 
    <スクリプトSRC = "JS / axios.js"> </ SCRIPT> 
</ HEAD> 
<BODY> 
    の<divのid = "アプリ"> 
        の<input type = "text" Vモデル= "都市"> 
        <ボタン@click >点击获取天气</ボタン> = "get_weather" 
    </ div> 
    <スクリプト> 
        せVM =新しいヴュー({ 
            "#アプリ"、:エル
            データ:{ 
                都市:、 "" 
            }、
            方法:{ 
                get_weather(){ 
                    // http://wthrcdn.etouch.cn/weather_mini?city=都市名
                    axios.get( "http://wthrcdn.etouch.cn/weather_mini?city=" + this.city)
                        .then(応答=> { 
                            にconsole.log(応答); 

                        })。キャッチ(エラー=> { 
                            にconsole.log(error.response)
                    })。
                } 
            } 
        })
    </ SCRIPT> 
</ body> 
</ HTML>

  

おすすめ

転載: www.cnblogs.com/eliwen/p/12047634.html