Giter VIP home page Giter VIP logo

Comments (2)

gbj avatar gbj commented on May 28, 2024

This doesn't contain a reproducible example so I can't tell for sure. At a glance: edit_url is reactive (it is a memo, so will react to changes in both novel_name and chapter_title), {format!(...)} is not reactive, so that could be one cause of the issue. Otherwise, not sure. If you can provide a reproducible example I'm happy to take a look.

from leptos.

yiwufen avatar yiwufen commented on May 28, 2024

这不包含可重复的示例,所以我无法确定。一目了然:是被动的(它是备忘录,所以会对两者的变化做出反应),不是被动的,所以这可能是问题的原因之一。否则,不确定。如果你能提供一个可重复的例子,我很乐意看一看。edit_url``novel_name``chapter_title``{format!(...)}

Thank you. I already know what the problem is, okay
this is a reproducible example, Ineed to use closures like href={move || format!("view/{}/{}", param_a(), param_b())}

use leptos::*;
use leptos_meta::*;
use leptos_router::*;

#[component]
pub fn App() -> impl IntoView {
    // Provides context that manages stylesheets, titles, meta tags, etc.
    provide_meta_context();

    view! {
        // injects a stylesheet into the document <head>
        // id=leptos means cargo-leptos will hot-reload this stylesheet
        <Stylesheet id="leptos" href="/pkg/tests-tag-a.css"/>

        // sets the document title
        <Title text="Welcome to Leptos"/>

        // content for this welcome page
        <Router>
            <main>
                <Routes>
                    <Route path="" view=ChangePramsB/>
                </Routes>
            </main>
        </Router>
    }
}

/// Renders the home page of your application.
#[component]
pub fn PageOne(param_a: ReadSignal<String>, param_b: ReadSignal<String>) -> impl IntoView {
    // Creates a reactive value to update the button
    let url = create_memo(move |_| format!("view/{}/{}", param_a(), param_b()));
    view! {
        <a href={format!("view/{}/{}", param_a(), param_b())}> test1 </a>
        <a href={url}> test2 </a>
    }
}

#[component]
fn ChangePramsB() -> impl IntoView {
    let (param_a, set_param_a) = create_signal(String::from("aa"));
    let (param_b, set_param_b) = create_signal(String::from(""));

    view! {
        
        <button on:click={move |_| set_param_b("bbb".to_string())}> "change param b" </button>
        <PageOne param_a=param_a param_b=param_b />

    }
}

from leptos.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.