【发布时间】:2021-12-10 20:48:07
【问题描述】:
我有以下代码:
@page "somePage"
<TeamsApplication RequireAuthentication="true">
<ApplicationTemplate Context="context">
Some HTML...
@*context works here*@
</ApplicationTemplate>
</TeamsApplication>
@code{
//context doesnt work here
}
在 ApplicationTemplate 标记内,我可以访问上下文对象实例,但不能在代码部分进行。有没有办法可以访问该实例及其值?
【问题讨论】:
-
我确实回复了这个,但重新阅读我不确定它是否正确。为什么不能从
ApplicationTemplate代码访问Context属性?它应该是代码中的[Parameter]?? -
如果不清楚,我很抱歉。显示的代码不是来自 ApplicationTemplate 组件。相反,来自包装在 ApplicationTemplate 中的其他组件。在 ApplicationTemplate 组件中正确设置了参数。
-
属性级联向下,而不是向上-因此在此处设置上下文属性将不起作用。我会在答案中提出一种方法