Could I send an option with Element to js function?
GISerliang opened this issue · comments
Summary
I had a js library and the constructor need seed an option with container, width and height. The container must be an HTMLElement. So I want to create a struct and send it as JsValue
to js libbrary use Rust
and wasm_bindgen
. But I got an error the trait `JsCast` is not implemented for `Options`
.
Additional Details
The struct like this:
struct Options {
pub container: web_sys::Element,
pub width: u32,
pub height: u32,
}
This isn't currently supported natively, see #2645. You should be able to do this with serde-wasm-bindgen
, though: see the 'Preserving JavaScript values' section of their docs for how to get the web_sys::Element
working.
This isn't currently supported natively, see #2645. You should be able to do this with
serde-wasm-bindgen
, though: see the 'Preserving JavaScript values' section of their docs for how to get theweb_sys::Element
working.
Thanks. I will try it.