ant-design-vue之form源码解读

ant-design-vue之form源码解读,第1张

form组件理解关键问题

1.form的form属性怎么和form-item的v-decorator对应起来?

遍历form-item的slots的子元素,利用vnode的属性vnode.data.directives来获取v-decorator绑定的对象

2.v-decorator 中的属性改变时,怎么联动form表单的数据进行修改?

在渲染(render)form-item的时候,先判断父组件是否存在要绑定的form属性,如果存在,给所有v-decorator的元素绑定默认的change事件(或者其他在rules设置的触发的事件),根据数据变化触发收集数据的函数

3.getFieldDecorator 和 v-decorator 有什么区别?

getFieldDecorator是一个返回vnode的函数,适用于jsx

v-decorator适用于模版

猜数字

建一个文本文档,输入以下代码,后缀改为.frm用vb打开就可以了

以下是程序源码:

VERSION 5.00

Begin VB.Form Form1

BorderStyle = 3 'Fixed Dialog

Caption = "猜数游戏"

ClientHeight= 3900

ClientLeft = 45

ClientTop = 435

ClientWidth = 4680

LinkTopic = "Form1"

MaxButton = 0 'False

MinButton = 0 'False

ScaleHeight = 3900

ScaleWidth = 4680

ShowInTaskbar = 0 'False

StartUpPosition = 3 '窗口缺省

Begin VB.CommandButton Command2

Caption = "重新开始"

Height = 615

Left= 2640

TabIndex= 2

Top = 2760

Width = 1095

End

Begin VB.CommandButton Command1

Caption = "确定"

Height = 615

Left= 840

TabIndex= 1

Top = 2760

Width = 1095

End

Begin VB.TextBox Text1

Height = 375

Left= 1200

TabIndex= 0

Top = 2040

Width = 2055

End

Begin VB.Label Label9

Caption = "戏"

BeginProperty Font

Name= "宋体"

Size= 24

Charset = 134

Weight = 400

Underline = 0 'False

Italic = 0 'False

Strikethrough = 0 'False

EndProperty

ForeColor = &H000080FF&

Height = 615

Left= 3720

TabIndex= 11

Top = 240

Width = 615

End

Begin VB.Label Label8

Caption = "游"

BeginProperty Font

Name= "宋体"

Size= 24

Charset = 134

Weight = 400

Underline = 0 'False

Italic = 0 'False

Strikethrough = 0 'False

EndProperty

ForeColor = &H00808080&

Height = 615

Left= 3240

TabIndex= 10

Top = 240

Width = 615

End

Begin VB.Label Label7

Caption = "数"

BeginProperty Font

Name= "宋体"

Size= 24

Charset = 134

Weight = 400

Underline = 0 'False

Italic = 0 'False

Strikethrough = 0 'False

EndProperty

ForeColor = &H0000FFFF&

Height = 495

Left= 2760

TabIndex= 9

Top = 240

Width = 615

End

Begin VB.Label Label6

Caption = "猜"

BeginProperty Font

Name= "宋体"

Size= 24

Charset = 134

Weight = 400

Underline = 0 'False

Italic = 0 'False

Strikethrough = 0 'False

EndProperty

ForeColor = &H00FF00FF&

Height = 495

Left= 2280

TabIndex= 8

Top = 240

Width = 735

End

Begin VB.Label Label5

Caption = "入"

BeginProperty Font

Name= "宋体"

Size= 24

Charset = 134

Weight = 400

Underline = 0 'False

Italic = 0 'False

Strikethrough = 0 'False

EndProperty

ForeColor = &H00FF0000&

Height = 615

Left= 1800

TabIndex= 7

Top = 240

Width = 855

End

Begin VB.Label Label4

Caption = "进"

BeginProperty Font

Name= "宋体"

Size= 24

Charset = 134

Weight = 400

Underline = 0 'False

Italic = 0 'False

Strikethrough = 0 'False

EndProperty

ForeColor = &H0000FF00&

Height = 735

Left= 1320

TabIndex= 6

Top = 240

Width = 735

End

Begin VB.Label Label3

Caption = "迎"

BeginProperty Font

Name= "宋体"

Size= 24

Charset = 134

Weight = 400

Underline = 0 'False

Italic = 0 'False

Strikethrough = 0 'False

EndProperty

ForeColor = &H00FFFF00&

Height = 735

Left= 840

TabIndex= 5

Top = 240

Width = 735

End

Begin VB.Label Label2

Caption = "欢"

BeginProperty Font

Name= "宋体"

Size= 24

Charset = 134

Weight = 400

Underline = 0 'False

Italic = 0 'False

Strikethrough = 0 'False

EndProperty

ForeColor = &H000000FF&

Height = 615

Left= 360

TabIndex= 4

Top = 240

Width = 495

End

Begin VB.Label Label1

Caption = "我这儿有1~10的整数,你猜猜看他是多少......"

Height = 375

Left= 480

TabIndex= 3

Top = 1320

Width = 3855

End

End

Attribute VB_Name = "Form1"

Attribute VB_GlobalNameSpace = False

Attribute VB_Creatable = False

Attribute VB_PredeclaredId = True

Attribute VB_Exposed = False

Dim x As Integer, y As Integer, z As Integer

Dim cishu As Integer

Private Sub Command1_Click()

If cishu = 3 Then MsgBox "已经猜3次了,这个数是" &x: Exit Sub

y = Val(Text1.Text)

If Text1.Text = "" Or Not IsNumeric(Text1.Text) Then

MsgBox "输入有误!请重新输入数字", 48

Text1.Text = ""

Text1.SetFocus

Exit Sub

End If

cishu = cishu + 1

Select Case x - y

Case Is <0

z = MsgBox("你猜数大了,请重猜。注意:你只有三次机会", 48 + 1)

Text1.Text = ""

Text1.SetFocus

Case Is >0

z = MsgBox("你猜数小了,请重猜。注意:你只有三次机会", 48 + 1)

Text1.Text = ""

Text1.SetFocus

Case Else

z = MsgBox("恭喜你猜中了!", 1)

End Select

End Sub

Private Sub Command2_Click()

cishu = 0

Randomize Timer

x = Int((Rnd * 10) + 1)

End Sub

Private Sub Form_Load()

cishu = 0

Randomize Timer

x = Int((Rnd * 10) + 1)

End Sub

代码结束

http://hi.baidu.com/卓7358/

欢迎来我空间


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/12115682.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-21
下一篇 2023-05-21

发表评论

登录后才能评论

评论列表(0条)

保存