<template>
<input @keyup="aaa"
v-model="val" />
<ul>
<li v-for="(item,index) in list"
:key="index">{{item.q}}</li>
</ul>
</template>
<script>
export default {
data() {
return {
val: 'html',
list: [],
timer: '',
}
},
mounted() {
},
methods: {
aaa() {
let _this = this
clearTimeout(this.timer) //清楚定时器
this.timer = setTimeout(() => {
this.FetchJsonp(
`https://www.baidu.com/sugrec?pre=1&p=3&ie=utf-8&json=1&prod=pc&from=pc_web&wd=${this.val}`
)
.then(function (response) {
return response.json()
})
.then(function (json) {
console.log('parsed json', json.g)
_this.list = json.g
})
.catch(function (ex) {
console.log('parsing failed', ex)
})
}, 1000)
},
},
updated() {},
}
</script>
<style scoped lang="less">
</style>
08-01
577
08-03
671
05-22
616
06-20
770
02-19
1821
02-28
771
09-13