Skip to content

Provide an easier way to import component specific scripts #61684

@danroth27

Description

@danroth27

Currently, to load a component specific script (.razor.js) you do something like this:

module = await JS.InvokeAsync<IJSObjectReference>("import", "./{PATH}/JsCollocation2.razor.js");

The "import" convention is a bit awkward to remember and you also need specify the script path. Could we make this simpler? Maybe provide an ImportAsync overload? Or maybe a declarative model, like this (suggestion from @DamianEdwards)?:

[JsModuleImport]
private IJSObjectReference? Module { get; set; }

@MackinnonBuck did some prototyping for component specific styles that work across render modes a while back that might also be worth considering: MackinnonBuck/blazor-js-components

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-blazorIncludes: Blazor, Razor Components

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions