minimise the code since I am using the same code only the content in p tags changes and component AccordionHeader header changes

后端 未结 1 2031
生来不讨喜
生来不讨喜 2020-12-02 02:40
  • I am new to js.
  • i need to display 6 sliders. each div when I click should open its corresponding content.
  • when i click the div again the content shou
1条回答
  •  栀梦
    栀梦 (楼主)
    2020-12-02 03:16

    try to use just one static and pass the text that will be on the p tag as a parameter, so you don't have a lot of functions there

         static accordion(ballInfo, content) {
            if (ballInfo.isRetrieving) {
                return (
                    
                );
            } else if (ballInfo.error) {
                return (
                    Unavailable
                );
            } else {
                return (
                    

    {{content}}

    ); } }

    so on your call to the accordion, you just add the other parameter

     
    
     
    

    0 讨论(0)
提交回复
热议问题