About the vue data-driven problem?

questions and requirements: it is said that vue is data-driven, so for requirements similar to accordion (click on a li, to display the contents of the corresponding li, how can it be achieved through data-driven without operating dom? )

such as the following structure, click on the text in the corresponding li element to display, while the text in the other brothers"li is hidden.

<ul>
    <li>1</li>
    <li>2</li>
    <li>3</li>
    <li>4</li>
    <li>5</li>
</ul>

<ul>
   <li v-for="(el, idx) in list"
       @click="() => triggerIdx = idx"
   >{{idx === triggerIdx? el : '' }}</li>
</ul>

data () {
    return {
        list: [0,1,2,3],
        triggerIdx: 0
    }
}

data-driven, to put it bluntly, is to use the data in ViewModel to control the style of DOM. Indirect operation of the DOM, upstairs code example is very clear


you can change data
to use v-if or dynamic: class control elements are visible

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b33076-2be44.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b33076-2be44.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?