美文网首页
当对象某一个初始值为undefined,但只发送有值的数据给后台

当对象某一个初始值为undefined,但只发送有值的数据给后台

作者: yuki20 | 来源:发表于2020-03-26 10:30 被阅读0次

    只发送有效的数据给后台操作方法

    //初始值是这样的

    listQuery: {

    pageIndex: 1,

    pageSize: 10,

    startTime: undefined,

    endTime: undefined,

    keyword: undefined,

    state: undefined,

    order: 1,

    showClose: 1

    },

    //如果有值是undefined的话,先转为字符串,再转为对象,只会留下有值的数据

    const listQuery = JSON.parse(JSON.stringify(this.listQuery))

    //打印出listQuery为

    {pageIndex: 1, pageSize: 20, order: 1, showClose: 1}

    相关文章

      网友评论

          本文标题:当对象某一个初始值为undefined,但只发送有值的数据给后台

          本文链接:https://www.haomeiwen.com/subject/nspquhtx.html