【发布时间】:2019-01-16 02:34:24
【问题描述】:
我定义了以下简单架构:
import SimpleSchema from 'simpl-schema';
export const Comments = new Mongo.Collection("comments");
export const CommentsSchema = new SimpleSchema({
comments: Array,
"comments.$": Object,
"comments.$.author": String
"comments.$.text": String
})
我有一个带有AutoForm 的组件来查看/编辑这个 cmets 数组:
import {ErrorsField, SubmitField, ListField} from "uniforms-semantic";
import AutoForm from 'uniforms-semantic/AutoForm';
<AutoForm schema={CommentsSchema} onSubmit={comments => this.updateRequest(comments)} model={this.props.comments}>
<ListField name={"comments"}/>
<ErrorsField/>
<SubmitField/>
</AutoForm>
this.updateRequest(...) 是一个调用 Meteor 后端函数来更新 Mongo 集合的函数。
我想自定义ListField,以便对于每条评论,"comments.$.text" TextField 显示为更大的文本框,允许换行。
我考虑过重写ListField 的自定义版本,但对于这样的小改动来说,这似乎是不必要的复杂。使用制服 API 添加此类小型自定义的最佳方法是什么?
【问题讨论】:
-
有什么理由不能只用 CSS 来做?
-
@ZackNewsham
TextField是默认为字符串生成的,它不允许换行符 AFAIK,所以我怀疑简单地编辑 CSS 是否可行。 -
我误解了这个问题,我的道歉。以为是关于造型。
标签: reactjs meteor semantic-ui meteor-autoform simple-schema