yew google sign-in issues

Viewed 77

I use yew, I want a button to appear on a webpage. I am following the official tutorial of Google : https://developers.google.com/identity/sign-in/web/sign-in

here is my code:

<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <meta name="google-signin-client_id"
        content="[my_id].apps.googleusercontent.com">
    <title>Yew App</title>
    <script src="https://apis.google.com/js/platform.js" async defer></script>
</head>

<body>

</body>

</html>

src/main.rs

use yew::prelude::*;

enum Msg {
    AddOne,
}

struct Model {
    value: i64,
}

impl Component for Model {
    type Message = Msg;
    type Properties = ();

    fn create(_ctx: &Context<Self>) -> Self {
        Self { value: 0 }
    }

    fn update(&mut self, _ctx: &Context<Self>, msg: Self::Message) -> bool {
        match msg {
            Msg::AddOne => {
                self.value += 1;
                // the value has changed so we need to
                // re-render for it to appear on the page
                true
            }
        }
    }

    fn view(&self, ctx: &Context<Self>) -> Html {
        // This gives us a component's "`Scope`" which allows us to send messages, etc to the component.
        let link = ctx.link();
        html! {
            <div>
                <button onclick={link.callback(|_| Msg::AddOne)}>{ "+1" }</button>
                <p>{ self.value }</p>
                <div class={classes!("g-signin2")}  > </div>
            </div>
        }
    }
}

fn main() {
    yew::start_app::<Model>();
}

The button is not displayed on the screen. What's the problem?

0 Answers
Related