model-libs
v0.0.3
Published
JS数据模型定义库,前后端数据结构轻松解耦,再也不担心后端果果不先定义接口文档而干着急了
Maintainers
Readme
How to use
const ModelTab = Model.define('ModelTab', {
id: {
type: Number,
field: 'id',
default: 0,
},
image1: {
// key和后端接口返回的key一致,就不需要写对应的field字段
type: String,
field: 'image',
default: '',
},
name: {
type: String,
field: 'name',
default: '',
},
noticeCategoryVOS: {
type: Array,
field: 'noticeCategoryVOS',
default: [],
},
type: {
type: Number,
field: 'type',
default: 0,
},
})
await axios.get('/user').then((res)=>{
let mapping = ModelTab.fromData(res.data)
console.log('---:',mapping)
})