我的 vb.net razor 2 代码“对象变量或未设置块变量”中有此错误。11号线
Line 9: Dim i = 0
Line 10:
Line 11: @For Each color In PageData("Colors")
Line 12: @<p style="background-color:@color; font-family:@Page.Fonts(i)">
Line 13: This paragraph is @color
这是我的 _PageStart.vbhtml 代码:
@Code
Layout = "~/Shared/_Layout1.vbhtml"
PageData("Colors") = {"LightCyan", "Gainsboro", "Chocolate"}
End Code
这是我的 default.vbhtml 代码:
@Code
Page.Title = "Level 1 Start page"
Layout = "~/Shared/_Layout2.vbhtml"
End Code
<h1>Testing _PageStart From Level 1</h1>
@Code
Dim i = 0
@For Each color In PageData("Colors")
@<p style="background-color:@color; font-family:@Page.Fonts(i)">
This paragraph is @color
</p>
i += 1
Next
End Code
<p><a href="/Level1/Page">Click</a> to visit Level 1</p>