SOURCE

var config = {
    resources: {
        /**
         * 配置数据(资源)
         * 首先我们需要配置`资源`、用于描述接口的`字段`组成、以及`api`的存取地址
         */
        res: {
            api: {
                // api前缀
                prefix:
                    'https://easy-mock.com/mock/5a0023effbbb09615044cb82/',
                // 读取数据接口
                read: 'read',
                // 更新数据接口
                update: 'update',
                // 更新数据接口
                list: 'list'
            },
            fields: {
                // 定义id和testRate两个字段
                id: {
                    type: 'text',
                    label: '文本'
                },
                testRate: {
                    type: 'rate',
                    label: '评分'
                }
            }
        }
    },
    /**
     * 配置区块
     */
    blocks: {
        /**
         * 接下来我们配置一个列表区块
         */
        listBlock: {
            type: 'list',

            // 指定block使用的资源为上面声明的res
            resource: 'res',

            events: {
                init: '@list'
            },
            fields: {
                  // 定义id字段,尝试覆盖 resources 中的字段
              		// 发现 blocks 的fields 字段并没有覆盖 resources 中的 fields 字段,和文档描述不太一致
              		// 文档https://vipshop.github.io/ams/block/api.html#fields
                 // 【用于block级别作用域的fields,重置resource中的默认配置】
                  id: {
                      type: 'text',
                      label: '文本'
                  },
                  // testRate: {
                  //     type: 'rate',
                  //     label: '评分'
                  // }
            }
        }
    },
    render: true
};

// 注册block、使用配置生效
ams.block('demo', config);
body {
  background: #fff
}
console 命令行工具 X clear

                    
>
console