Comments (1)
get:用于将数据转换为asm组件所需要的格式
比如接口返回一个['a', 'b']的数据,但是ams组件field需要的数据格式是‘a,b’,那么就需要在get函数里面做数据转换,['a','b'] => 'a,b'
当使用ams提供的api接口请求给data赋值,或者直接在action里面用this.data.field = xxx设置的数据都会经过get函数处理为满足ams组件需要的数据格式
set:用于将ams组件所默认的格式处理为用户及接口所需要的真实数据
当用户输入input的内容或者选择select框的值这些交互时,ams会设置数据到data里面,然后经过set的处理,在data设置用户所需要的数据格式
// ams select默认数据为字符拼接
data.selectField = 'a,b'
// 用户接口数据需要数组
data.selectField = ['a', 'b']
selectField: {
type: 'select',
label: '多选',
props: {
options: [
{
value: 'a',
label: '军大佬'
},
{
value: 'b',
label: '军85'
},
{
value: 'c',
label: '大佬军'
}
]
},
get(val) {
// 用于将数据转换为asm组件所需要的格式
// 数组转字符
if(val) {
return val.join(',')
}
},
set(val) {
// 用于将ams组件所默认的格式处理为用户及接口所需要的真实数据
// 字符转数组
if(val) {
return val.split(',')
}
}
}
from ams.
Related Issues (20)
- [请教] resource fields 显示了 API 的 部分字段, editItemDialog 希望编辑 API Item 的全部字段 HOT 2
- [文档疑惑] 用于block级别作用域的fields,重置resource中的默认配置,貌似并未覆盖 HOT 3
- [文档纠错]导航中 示例 404 ,烦请修正
- [建议] 增强 request 模块错误处理能力,以及期待暴露更多 error 相关信息
- [Bug Report] @ams-team/block-nav-user 404 not found HOT 1
- [求教] 列表区块的增删改查场景中,某个字段 编辑Dialog 和 显示在 Table 中,是否可以采用不同 type? HOT 3
- [源码理解] callAction 解析
- [Bug Report] form label width not work? HOT 2
- Eslint 报警告 'function-call-argument-newline'
- 各个组件能串起来吗?譬如组件1的数据能在组件2中放问到 HOT 1
- https://vipshop.github.io/ams/api/try.html 生成的页面模板中的 ams-init 是做什么的呢?
- [Bug Repot] https://vipshop.github.io/ams/api/try.html 中的:下一节:快速起步 丢失? HOT 1
- 将 easy-mock 的配置导出为文件?
- operations 中的配置 field 嵌套实在是一言难尽,希望尽早改进! HOT 2
- Table 最后一行折叠不了
- 缺少CONTRIBUTE指引
- 关于额外引入 block ,例如将表单表格隔离,不在同一个block配置内?
- 如何在数据请求时,监听其失败返回,并做其他操作? HOT 2
- 国际化或者多语言怎么支持?
- [Bug Report] _getValue 方法重新获取了 表单中手动清除掉变量,发送了无关数据 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ams.