一些封装函数,主要供内部使用
将接口的返回属性值转小写,如Return_data变为return_data
属性名 | 类型 | 默认值 | 说明 |
---|---|---|---|
obj | Object | 一般是接口返回的data | |
deep | Boolean | false | 深度转化,可选值true。默认只转化obj的最外层键 |
obj
格式示例:
键 | 值 | 说明 |
---|---|---|
Return_code | Number|String | 状态码 |
Return_data | any | 返回数据 |
Return_msg | String | 提示文案 |
示例代码: 1、按需引入
import { toLowerKey } from 'miduo-utils'
async getData() {
let res = await api()
const d = toLowerKey(res, true)
// const d = toLowerKey(res)
}
2、全局注入
import MdUtils from 'miduo-utils'
Vue.use(MdUtils)
// vue页面使用
const d = this.$toLowerKey(res, true)