如果我在像JavaScript这样的库中定义了three.js类,那么如何从Blazor WebAssembly调用构造函数并实例化对象呢?
我试过了
var threeJs = await Js.InvokeAsync<IJSInProcessObjectReference>("import", "https://threejsfundamentals.org/threejs/resources/threejs/r125/build/three.module.js");
var scn = threeJs.Invoke<IJSInProcessObjectReference>("new THREE.Scene");
但这会导致错误地说"Microsoft.JSInterop.JSException: Could not find 'new THREE.Scene' ('new THREE' was undefined).
“
是否可以实例化JavaScript类而不使用JavaScript包装器函数来实例化对象?
发布于 2022-06-16 19:52:22
您不能单独调用new THREE.Scene
。你可以做一些像const scene = new THREE.Scene
这样的事情。但是,我不知道在JSInterop中实例化变量有什么好处。
https://stackoverflow.com/questions/72650815
复制相似问题