Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

<div class="historyTag">
           <ul>
                <li class="history">搜索历史</li>
                <li class="clearhistory" v-on:click="clearHistory">清空历史</li>
           </ul>
            <ul>
                <li v-for="(item,index) in this.$store.state.searchArr"  >
<!--                   不包住整个是为了能点击删除 不然跳转-->
                    <router-link to="/mine/searchPage/searchResult" v-on:click="search(item.index,$even,'history')">
                       <span class="itemName">{{item}}</span>
                    </router-link>
                       <span class="deleteIcon"><img v-on:click="deleteHistory(index)" src="../img/playimg/close(2).svg"></span>
                    
                </li>
            </ul>
        </div>

我想在search函数中使用li循环的index索引 请问怎么实现简单的


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
614 views
Welcome To Ask or Share your Answers For Others

1 Answer

给 search 添加一个参数,index 作为实参直接用就可以了

如有必要,重命名 index 避免混淆


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...