我正在编写一个asp net core应用程序.
我想要实现的是使用 Javascript读取视图中的模型.
我找到了这段代码,但是当我运行它时,我收到此错误:
我想要实现的是使用 Javascript读取视图中的模型.
我找到了这段代码,但是当我运行它时,我收到此错误:
‘IJsonHelper’ does not contain a deFinition for ‘Encode’ and no extension method ‘Encode’ accepting a first argument of type ‘IJsonHelper’ Could be found (are you missing a using directive or an assembly reference?)
我该怎么办呢?
调节器
public async Task<IActionResult> Index() { return View(await _context.Bolla.ToListAsync()); }
视图
@model IEnumerable<ps0001.Models.Bolla> <script> var bolla = @Html.Raw(Json.Encode(Model)); </script>