1
Day2 模拟百度翻译
// 请求方式:get
// 请求参数:
// (1)words:需要翻译的文本
// (2)lang:需要翻译的语言
async 'obj.word'(newValue, oldValue) {
const res = await axios({
url: 'https://applet-base-api-t.itheima.net/api/translate',
params: {
word: newValue
}
})
console.log(res.data.data);
this.result = res.data.data
}
Day3 小黑记事本
async getList() {
const res = await axios.get('https://applet-base-api-t.itheima.net/bill', {
params: {
creator: 'slx'
}
})
// console.log(res.data);
this.list = res.data.data
this.myChart.setOption({
series: [
{
// data: [
// { value: 1048, name: 'Search Engine' },
// { value: 735, name: 'Direct' },
// ],
// ()必须加,不然会以为是代码段
data: this.list.map(item => ({
value: item.price, name: item.name }))
}
]
})
增
Day3 小黑记事本
post类型的请求 不用加
data:{
}
const res = await axios.post('https://applet-base-api-t.itheima.net/bill', {
// data: { post不用写这个
creator: 'slx',
name: this.name,
price: this.price
// }
})
删
Day3 小黑记事本
async del(tt) {
// 注意这个的写法,`` $
const res = await axios.delete(`https://applet-base-api-t.itheima.net/bill/${
tt}`)
// console.log(res);
this.getList()
}