search

Home  >  Q&A  >  body text

javascript - There is a button in the vue subcomponent. Clicking it will change the state. This state is obtained by the parent component through the interface, which means that the state of the interface needs to be changed dynamically.

A component (parent component) obtains a batch of data through the interface. The parent component props are passed to the child component (B)
After the child component renders this batch of data, there is a button that needs to be clicked to change the current state, such as from "Add to Shopping Cart" to "Add to Shopping Cart". I don’t know how to handle it so that it can dynamically change the state while clicking?
Is the event customized through sub-component?
Don’t know how to write?

三叔三叔2733 days ago1020

reply all(2)I'll reply

  • 滿天的星座

    滿天的星座2017-07-05 11:05:53

    What is the status controlled by?
    If your sub-component controls data state changes
    Of course it is done through the sub-component custom event
    It mainly depends on how you layout it

    reply
    0
  • 为情所困

    为情所困2017-07-05 11:05:53

    It is recommended to use vuex to manage status https://vuex.vuejs.org/

    reply
    0
  • Cancelreply