zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    .Net Core主机配置
    .NET Core 初识
    控制反转IOC,依赖注入DI理解
    依赖倒置原则解析,理解面向抽象编程
    工厂模式
    IOC 概念
    利用Comparator排序
    使用Integer类实现二叉树排序
    先按成绩由高到低,相等则按年龄由低到高
    对象销毁之前进行某些操作
  • 原文地址:https://www.cnblogs.com/manban/p/11087297.html
Copyright © 2011-2022 走看看