vue中fetch請求


1. 請求方式:get

請求參數:menuName

返回的結果:data

created(){

         this._initPageData()

    },

    methods:{

            _initPageData(){

             fetch('http://localhost:3000/category/searchcategory?menuName='+this.menuName, {

              method: 'get'

            }).then(response => response.json()).then(data => {

               this.category = data.data;

               // console.log(this.category)

            })

          }

2. 請求方式:post

請求參數:username,password

返回的結果:data

fetch('http://localhost:3000/users/register', {

         method: 'POST',

         headers: { 'Accept': 'application/json', 'Content-Type': 'application/json'},

         body: JSON.stringify({ username:userPhone, password: userPassword})

         }).then(response => response.json()).then(data => {  

               console.log(data)

               if(data.state){

                alert(dat


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM