// pages/meishi/meishi.js
Page({
/**
/**
},
getValue: function(e) {
let value = e.detail.value
this.setData({
inputValue: value
})
},
//text
text: function(){
wx.request({
url: https://apis.tianapi.com/dream/index
, //仅为示例,并非真实的接口地址
method:'GET',
data: {
key: '5ca3892a9ad11ad15cdcb2bb69d5af8f',
num:5,
word:'龙', //谁能教教我,这里怎么改,可以让我不用事先声明这个参数,而是我自己输入再去调用api
},
success: function (res){
console.log(res)
self.setData({
dreamResult:res.data.result.list,
dreamCode:res.data.result.code
})}
})
},
/**
},
/**
},
/**
},
/**
},
/**
},
/**
}
})
那就加个输入框的点击事件,输入后在调用这个方法
text 是一个函数 。那你 在 input的输入事件里 调用就行 。
getValue: function(e) {
let value = e.detail.value
this.setData({
inputValue: value
},()=>{
this.text();
})
},
word就用 变量
word : this.inputValue