Giter Site home page Giter Site logo

Comments (1)

EdwardQ avatar EdwardQ commented on June 12, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.