Show how to use web-sys::console::log from the console_log example

This commit is contained in:
Andrew Chin
2018-08-17 22:54:59 -04:00
parent 7a08da9205
commit 4a994da904
3 changed files with 13 additions and 2 deletions

View File

@ -1,9 +1,14 @@
#![feature(use_extern_macros)]
extern crate wasm_bindgen;
extern crate web_sys;
use wasm_bindgen::prelude::*;
// You can use the console bindings from web-sys...
use web_sys::console;
// ... or you can manually write the bindings yourself
#[wasm_bindgen]
extern "C" {
#[wasm_bindgen(js_namespace = console)]
@ -19,4 +24,7 @@ pub fn run() {
log("Hello from Rust!");
log_u32(42);
log_many("Logging", "many values!");
console::log(JsValue::from("Another message from rust!"));
console::log(JsValue::from(56u32));
}