我如何在Blazor服务器端呈现Javascript?

问题描述 投票:0回答:1

我必须在Blazor服务器端项目中使用javascript库。

该库正在用于连接到APP。它需要通过在后端使用get方法获取访问令牌来进行初始化。

现在,get方法可以成功获取访问令牌,下一步是将其呈现在字体末端以初始化库。

但是,我想在code中添加一个_Host.cshtml块,但似乎根本不支持。

enter image description here

然后,我尝试将代码和script块修改为index.cshtml。好吧,现在它报告script块尚未在网页上呈现。

enter image description here

我该如何解决?你能帮我吗?谢谢。


Blazor与没有Rendersection方法的原始asp.net内核不同。

这里是关于这个的另一个问题:@RenderSection Equivalent in Blazor?

asp.net-core .net-core blazor
1个回答
0
投票

您只能添加Blazor Componenets的JavaScript outside。您可以将它们添加到index.html或_Host.cshtml中。您所有的外部功能都将存在,或位于组件dll中。您可以从Blazor调用这些函数并传递结果

© www.soinside.com 2019 - 2024. All rights reserved.