Movatterモバイル変換


[0]ホーム

URL:


Skip to main content
⭐️ If you like Blazor Bootstrap, give it a star onGitHub! ⭐️

Blazor Script Loader

Documentation and examples for using the Blazor Bootstrap Script Loader component.

Blazor Progress - How it works

Script Loader Parameters

NameTypeDefaultRequiredDescriptionAdded Version
AsyncboolfalseGets or sets the async.1.11.0
ScriptIdstring?nullGets or set the script id.1.11.0
Sourcestring?null✔️This parameter specifies the URI of an external script; this can be used as an alternative to embedding a script directly within a document.1.11.0

Script Loader Events

NameDescriptionAdded Version
OnErrorAn event that is fired when a script loading error occurs.1.11.0
OnLoadAn event that is fired when a script has been successfully loaded.1.11.0

How it works

In the following example, the jQuery script is loaded using the Script Loader component.

<ScriptLoaderAsync="true"
Class="mt-4"
ScriptId="script1"
Source="//cdn.jsdelivr.net/npm/jquery@3.7.1/dist/jquery.min.js"/>
Test

To test whether the jQuery script has been loaded successfully, run$('#script1')[0] in the browser console.

Blazor Script Loader - Test whether the jQuery script has been loaded successfully

See demo here.

Events

In the following example, an incorrect script source is specified.This is why theOnError callback event is called, and the message is updated with the error message.

<ScriptLoaderAsync="true"
Class="mt-4"
OnLoad="OnScriptLoad"
OnError="OnScriptError"
ScriptId="script2"
Source="//cdn.jsdelivr.net/npm/jquery@3.7.1/dist/jquery.min1.js"/>

<divclass="text-danger">@message</div>
@code{
string? message;
privatevoidOnScriptLoad()=> message="Script loaded successfully.";
privatevoidOnScriptError(string errorMessage)=> message= errorMessage;
}

[8]ページ先頭

©2009-2025 Movatter.jp