老师,为什么我删除历史搜索的时候,动画没有生效??

老师,为什么我删除历史搜索的时候,动画没有生效??

<template>

    <div class="history" v-if="historys.length">

        <transition class="history-list" name="historyItem" tag="ul">

            <div>

                <li class="history-item" v-for="(item, index) in historys" :key="index"  

                @click="$_search_selectItem(item)">

                    <div class="historyItem" >{{item.hotWord}}</div>

                    <i class="iconfont icon-delete" @click.stop="clear(item)"></i>

                </li>

            </div>

        </transition>

        <div class="history-delete">

            <div class="history-delete-wrapper" @click="showConfirm">

                <i class="iconfont icon-clear"></i>

                <span>清空历史搜索</span>

            </div>

        </div>

        

    </div>

</template>

<script>


import storage from 'assets/js/storage'

import {searchMixin} from 'assets/js/mixins'

import {SEARCH_HISTORY_KEYWORD_KEY} from './config';


export default {

    name: 'SearchHistory',

    mixins: [searchMixin],

    data() {

        return {

            historys: []

        }

    },

    components: {

        

    },

    created() {

        this.getHistorysMsg()

    },

    methods: {

        getHistorysMsg() {

            const historyMsg = storage.get(SEARCH_HISTORY_KEYWORD_KEY, [])

            if(historyMsg && historyMsg.length > 0) {

                this.historys = historyMsg

            }

        },

        clear(item) {

            this.historys = this.historys.filter(val => val.hotWord !== item.hotWord)

            storage.set(SEARCH_HISTORY_KEYWORD_KEY, this.historys)

        },

        showConfirm () {

            this.$emit('show-confirm')

        }

    }

}

</script>

<style lang="scss" scoped>

    .history {

        background-color: white;


        &-list {

            width: 100%;

        }

        &-item {

            width: 100%;

            display: flex;

            justify-content: space-between;

            height: 40px;

        }

        &-delete {

            width: 100%;

            display: flex;

            justify-content: center;

            align-items: center;


            &-wrapper {

                width: 80%;

                border: 1px solid black;

                height: 40px;

                line-height: 40px;

                text-align: center;

                font-size: 18px;

                border-radius: 4px;

                // margin: 0 auto;

                .iconfont {

                    font-size: 18px;

                }

            }

        }

    }

    .historyItem {

        &-enter-active,

        &-leave-active {

            transition: height 0.1s;

        }


        &-enter,

        &-leave-to {

            height: 0;

        }

    }

</style>


正在回答 回答被采纳积分+1

登陆购买课程后可参与讨论,去登陆

1回答
好帮手慕糖 2020-03-29 19:09:17

同学你好,是指左侧的“X”,还是按钮“清空历史搜索”。

http://img1.sycdn.imooc.com//climg/5e8081a909efea8406990177.jpg

只是动画的话,是那部分,建议:可以详细的描述下,便于准确的定位与解决问题。

祝学习愉快~

  • 提问者 Syrena3447375 #1
    老师,是右侧的“X"
    2020-03-29 19:37:15
  • 提问者 Syrena3447375 #2
    老师,我的动画可以用了
    2020-03-29 20:20:01
问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
请稍等 ...
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师