我有一个接受tagType
道具的组件。如果该标签类型为链接或 a ,则需要link
道具。如果tagType
是按钮或输入,则不需要link
道具。
这是我到目前为止的内容,但无法弄清楚如何设置link
的类型:
type linkTagTypes = 'Link' | 'a'
type nonLinkTagTypes = 'button' | 'input'
type tProps = {
tagType: linkTagTypes | nonLinkTagTypes,
link: string,
...
}
答案 0 :(得分:1)
一种可能性是使用联合类型,但不使用data = chart.aggregate([{ $project: { isoDate: { $add: [new Date(0), { $multiply: [ 1000, "$created_on"]} ] } } }, { $project: {month: { $month: "$isoDate"} } },{ $group: { _id: "$month",count: {$sum: 1} } }])
output = []
trs = ""
for x in data:
#output.append((stage1))
#data = chart.aggregate([{"$group": {"_id":"$created_on"}}])
# created_on = x['created_on']
# trs += "<tr><td>"+str(created_on)+"</td></tr>"
# #print str(output)
labels = ["January","February","March","April","May","June","July","August","September","October","November","December"]
#values = [10,9,8,7,6,4,7,8]
return render_template('chart.html', values=x, labels=labels)
属性,而是使用tagType
属性,如下所示:
tProps
检查该游乐场的用途:Make link required only in one case