Vue開発リクエスト

1

Day2 は Baidu 翻訳をシミュレートします

// 请求方式: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 Xiaohei Notepad
投稿タイプリクエストを追加する必要はありません

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()
            }

おすすめ

転載: blog.csdn.net/weixin_63681863/article/details/132845818