亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

vue 關于置頂div的問題

vue 關于置頂div的問題

侃侃爾雅 2019-03-21 18:19:51
兩個div,點擊第二個div里面的置頂,會和第一個互換位置,會排到首個位置,如下圖以下是代碼(已經把css部分代碼忽略)模板代碼<template>    <div>        <div            class="follow_contents_wrap"            v-for="(list,index) in follow_contents"            @mouseenter="btnsNow=index"            @mouseleave="btnsNow=-1"            v-dragging="{ item : list,list : follow_contents }"            :key="list.title">            <div                 class="follow_contents_title_wrap">                <div                     class="follow_contents_title_left"                    @click="showList===index ? showList=-1 : showList=index"                    :style="{borderBottom: '1px solid rgba(240,240,240,'+ changebackgroundopacity +')'}">                    <div                         class="follow_contents_title_icon"                        :class="index===showList?'':'special_none'">                        <em></em>                    </div>                    <div class="follow_contents_title_name">                        <span>                            {{ list.title }}                        </span>                    </div>                    <div class="follow_contents_title_counts">                        <span>                            (                            {{ list.counts }}                            )                        </span>                    </div>                    <div class="div_clear"></div>                </div>                <div                     class="follow_contents_title_right"                    v-show="index===btnsNow">                    <div>                        <span>添加</span>                    </div>                    <div                        :class="index===0 ? 'top_index' : ''"                        @click="">                        <span>置頂</span>                    </div>                    <div class="div_clear"></div>                </div>            </div>            <div js部分代碼
查看完整描述

3 回答

?
Helenr

TA貢獻1780條經驗 獲得超4個贊

let arr = [0, 1, 2, 3]

function toTop (index) {

    if (index >= arr.length || index === 0) {

        return

    }

    let tempArr = JSON.parse(JSON.stringify(arr))

    return tempArr.splice(index, 1).concat(tempArr)

}


查看完整回答
反對 回復 2019-03-28
?
慕森卡

TA貢獻1806條經驗 獲得超8個贊

https://img1.sycdn.imooc.com//5c9c270e0001c1c507430157.jpg已經解決,謝謝各位大神,如圖

查看完整回答
反對 回復 2019-03-28
  • 3 回答
  • 0 關注
  • 2277 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號