Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

Function undefined in blazor

$
0
0

I'm using Blazor WASM with JavaScript for Web API. I have this error:

Error: Could not find 'AddDb' ('AddDb' was undefined).

JavaScript

export function AddDB() {const DB_NAME = 'product';const DB_VERSION = 1; // Use a long long for this value (don't use a float)const DB_STORE_NAME = 'MHCproduct';var db;// Used to keep track of which view is displayed to avoid uselessly reloading itvar current_view_pub_key;function openDb() {    console.log("openDb ...");    var req = indexedDB.open(DB_NAME, DB_VERSION);  }  }

Razor page

<div class="row"><span class="cuscol-100" style="text-align:center;background-color:white"><button class="btn btn-primary" style="width:100%" @onclick="()=>StartDB(elementX)">Calculate</button></span></div>@code{    string name = string.Empty;    IJSObjectReference module;    private ElementReference elementX;    async Task StartDB(ElementReference element)    {        module = await JSRuntime.InvokeAsync<IJSObjectReference>("import", "./js/JavaScript.js");        await module.InvokeVoidAsync("AddDb", element);        Console.WriteLine("Berjaya");    }}

Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>