< Body >
< div ID = "App" >
<-!
V-form field Model listener, the value of the form field passed its attribute value,
the attribute value data which then pass data (and its attribute value must the data object which exists)
other places which data can be called by the form fields of the data transmitted
.lazy updated loses focus
->
< INPUT type = "text" V-model.lazy = "Good" @ keyup.enter = "JSONP" >
< Button @click = "JSONP" > HTTP request </ Button >
< P V-for = "RES in Result" >{{res[0]}}</p>
</ Div >
< Script the src = "./ Base / vue.js" > </ Script >
< Script the src = "https://cdn.bootcss.com/vue-resource/1.3.4/vue-resource.min .js " > </ Script >
< Script >
// request interface
// http://suggest.taobao.com/sug?code=utf-8&q= the callback = CB product Categories &
var VM = new new Vue ({
EL : " #app " ,
Data: {
Good: "" ,
Result:[][]
},
methods:{
JSONP () {
// JSONP ( 'request address', {configuration})
the this $ http.jsonp (. ' http://suggest.taobao.com/sug ' , {
// parameters carried
params: {
code: " UTF-. 8 " ,
Q: the this .good
}
.}) the then (RES => {
// data returned res.data
the this .Result = res.data.result
})
}
}
})
</script>
</body>