如何在加载表单时将“onDemand”设置为默认值? (背景:有一个隐藏的文本框,只有在选中“Predefine”时才能看到。不幸的是,当表单首先被加载时它是可见的。此时我想到默认情况下检查onDemand以保持文本框不可见在第一页加载)
{"key":"discountType","type":"radioType", "templateOptions":{"options": [{"name":"OnDemand","value":"OnDemand"},{"name":"Predefined","value":"Predefine"}]}},
{"key":"discValue","type":"input","templateOptions": {"type":"input"}, hideExpression: "model.discountType=='OnDemand'"}
]
}
答案 0 :(得分:0)
睡了之后做了一些试验和错误,我得到了它。 discount.discountInfo.discType = “按需”;解决了它。
var discount = this;
discount.title = title;
discount.discountInfo = {};
discount.fields=[{"key":"discountType","type":"radioType", "templateOptions":{"options": [{"name":"OnDemand","value":"OnDemand"},{"name":"Predefined","value":"Predefine"}]}},
{"key":"discValue","type":"input","templateOptions": {"type":"input"}, hideExpression: "model.discountType=='OnDemand'"}
]
discount.discountInfo.discType="OnDemand";