wasm_macro 0.1.4

Collections of useful macros for wasm
Documentation

Collections of useful macros for wasm

Examples

use wasm_macro::*;
//location_assign
onclick:move|_|{
    location_assign!("/demo");// nevigate to /demo
}
//location_herf
onclick:move|_|{
    let herf = location_herf!();
    console_log!(herf); //get current location herf 
}
//location_reload
onclick:move|_|{
    location_reload!(); //reload current location
}
//query_selector
onclick:move|_|{
let main_div = document_query_selector!(".main");
match main_div{
    Some(div) => {
        div.append_child(&document_create_element!("div").clone_node().unwrap());
    },
    None => {},
    }
}
//query_selector_all
onclick:move|_|{
let main_div = document_query_selector_all!(".main");
match main_div.get(0){ //frist of NodeList
    Some(div) => {
        div.append_child(&document_create_element!("div").clone_node().unwrap());
    },
    None => {},
}
// get inner_html
onclick:move|_|{
 console_log!(element_inner_html!(".main"));
}
//set inner_html
onclick:move|_|{
 element_set_inner_html!(".main","<h1>hello</h1>");
}

//console.log()
 onclick:move|_|{
 console_log!(element_inner_html!(".main"));
}

//document_base_uri!() return base_uri
use wasm_macro::*;
onclick:move|_|{
    console_log!(document_base_uri!());
}