84669 人學習
152542 人學習
20005 人學習
5487 人學習
7821 人學習
359900 人學習
3350 人學習
180660 人學習
48569 人學習
18603 人學習
40936 人學習
1549 人學習
1183 人學習
32909 人學習
RT
除了用原生,有沒有什麼Vue自帶的方法和技巧?感謝~
var el = document.getElementById('container-id'); el.addEventListener('click', function(e) { var p = e.target.parentElement; var index = Array.prototype.indexOf.call(p.children, e.target); }
只是提供個思路
test test test test test
export default { methods: { getIndex (e) { const parent = this.$refs.containBox.xxx // 上面我忘记xxx是什么了,反正可以获取父元素,console.log(this.$refs)看看 const index = Array.prototype.indexOf.call(parent.children, e.target) // ... } } }
沒有循環哪來的index呢?? index是相對哪裡的index呢
用原生 給li相同的class類別名稱 document.queraySelectAlll來取得li數組 這下就有index了
沒太明白你說的什麼意思。 。 。 。沒用v-for列表資料怎麼載入出來的?依照dom找節點順序號碼也要有dom節點。 。 。
只是提供個思路
沒有循環哪來的index呢?? index是相對哪裡的index呢
用原生 給li相同的class類別名稱 document.queraySelectAlll來取得li數組 這下就有index了
沒太明白你說的什麼意思。 。 。 。
沒用v-for列表資料怎麼載入出來的?依照dom找節點順序號碼也要有dom節點。 。 。