我有定义类型的道具,但我希望它们的最后一个接受任何类型的值
props: {
Size: String,
Label: String,
Name: String,
value: Any
}
我能做到吗?
答案 0 :(得分:13)
答案 1 :(得分:1)
当你有定义类型的 props 时支持 props 类型 any
:
props: {
custom1: null, // set as `null`
custom2: undefined, // or `undefined`
// if you need to add extra rules, simply don't set the `type` prop
custom3: {
required: true,
//... rest of your props
}
}
答案 2 :(得分:0)
这就是我通过皮棉验证的方法。
您可以在这里进行实际验证。
lodash提供了许多方便的方法来检查类型
Private Sub TreeDraw(ByVal TreeRoot As String)
'Throw New NotImplementedException
TVNew.Nodes.Clear()
Dim con = New OleDbConnection(StrConn)
Dim strSql = "Select * from Tree WHERE TreeName = '" & _
TreeRoot.Trim & "' AND levelNum = 0" & _
" ORDER BY nodeID ASC"
Dim da = New OleDbDataAdapter(strSql, con)
Dim ds As New DataSet
Dim lvl = 0
Try
da.Fill(ds, "Tree")
Do While ds.Tables(0).Rows.Count > 0
If lvl = 0 Then
TVNew.Nodes.Add(ds.Tables(0).Rows(0)(4))
Else
For Each row As DataRow In ds.Tables(0).Rows
For Each node As TreeNode In TVNew.Nodes
If node.Text = row(3) Then
TVNew.SelectedNode = node
TVNew.SelectedNode.Nodes.Add(row(4))
End If
Next
Next
End If
'MsgBox(lvl.ToString)
lvl = lvl + 1
da.Dispose()
ds.Tables.Clear()
strSql = "Select * from Tree WHERE TreeName = '" & _
TreeRoot.Trim & "' AND levelNum =" & lvl & _
" ORDER BY nodeID ASC"
da = New OleDbDataAdapter(strSql, con)
da.Fill(ds, "Tree")
Loop
Catch ex As Exception
MsgBox(ex.Message & Chr(13) & da.SelectCommand.CommandText _
, vbOKOnly, Application.ProductName)
Exit Sub
End Try
TVNew.ExpandAll()
End Sub