search

Home  >  Q&A  >  body text

javascript - Several places on a page need to be clicked to display and then clicked to hide. How to implement this in Vue?

As shown in the figure, click on the first li and all the p's of li will be displayed.
Clicking on the second li, the first li and the third li have also changed. How can I click which li and display the p element in which li? . .



##

phpcn_u1582phpcn_u15822819 days ago523

reply all(6)I'll reply

  • 高洛峰

    高洛峰2017-05-19 10:15:09

    Set one current

    @click = "current = 1"
    v-show = "current == 1"

    reply
    0
  • 天蓬老师

    天蓬老师2017-05-19 10:15:09

    You’ll understand if you look at the code:

    reply
    0
  • 天蓬老师

    天蓬老师2017-05-19 10:15:09

    Correct answer on the first floor. You can also use v-if. However, it is recommended that the @click binding function be written in a more standardized way in methods.

    reply
    0
  • 我想大声告诉你

    我想大声告诉你2017-05-19 10:15:09

    Think data driven⤴

    reply
    0
  • 为情所困

    为情所困2017-05-19 10:15:09

    Should this be written using event delegation? You bind click to ul, determine which li the clicked event.target is, and then switch the display, it should be fine

    reply
    0
  • PHPz

    PHPz2017-05-19 10:15:09

    Set three variables

    reply
    0
  • Cancelreply