微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

客户端 MatBlazor matbutton 找不到 initmatblazor 未定义

如何解决客户端 MatBlazor matbutton 找不到 initmatblazor 未定义

我正在尝试将 MatBlazor 添加到我的 WASM 客户端,但出现错误

blazor.webassembly.js:1 crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
      Unhandled exception rendering component: Could not find 'matBlazor.matButton.init' ('matBlazor' was undefined).
      Error: Could not find 'matBlazor.matButton.init' ('matBlazor' was undefined).
          at https://localhost:5001/_framework/blazor.webassembly.js:1:1287
          at Array.forEach (<anonymous>)
          at e.findFunction (https://localhost:5001/_framework/blazor.webassembly.js:1:1247)
          at b (https://localhost:5001/_framework/blazor.webassembly.js:1:2989)
          at https://localhost:5001/_framework/blazor.webassembly.js:1:3935
          at new Promise (<anonymous>)
          at Object.beginInvokeJSFromDotNet (https://localhost:5001/_framework/blazor.webassembly.js:1:3908)
          at Object.w [as invokeJSFromDotNet] (https://localhost:5001/_framework/blazor.webassembly.js:1:64218)
          at _mono_wasm_invoke_js_blazor (https://localhost:5001/_framework/dotnet.5.0.1.js:1:190800)
          at do_icall (<anonymous>:wasm-function[10596]:0x194e58)
Microsoft.JSInterop.JSException: Could not find 'matBlazor.matButton.init' ('matBlazor' was undefined).

它正在 .NET Core 上运行,但开始在 .Net 5.0 上抛出错误

我一定是遗漏了一步什么的。

建议?

解决方法

问题原来是我忘记在 index.html 中包含 MatBlazor 链接

<head>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no" />
  <title>BlazingShows</title>
  <base href="/" />
  <!--<link href="css/bootstrap/bootstrap.min.css" rel="stylesheet" />-->
  <link href="css/app.css" rel="stylesheet" />
  <link href="BlazingShows.Client.styles.css" rel="stylesheet" />
  <link href="_content/Blazored.Modal/blazored-modal.css" rel="stylesheet" />
  <link href="_content/Syncfusion.Blazor/styles/material.css" rel="stylesheet" />
  <link href="_content/MatBlazor/dist/matBlazor.css" rel="stylesheet" />
  <script src="_content/MatBlazor/dist/matBlazor.js"></script>
</head>

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。