美文网首页
vue 多组件过渡

vue 多组件过渡

作者: newway_001 | 来源:发表于2019-07-11 15:41 被阅读0次

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title>多组件的过渡</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2.6.10/dist/vue.js"></script>
    </head>
    <style>
    .component-fade-enter-active, .component-fade-leave-active {
    transition: opacity .3s ease;
    }
    .component-fade-enter, .component-fade-leave-to {
    opacity: 0;
    }
    </style>
    <body>
    <div id="app">

    <input type="radio" name="aa" value="v-a" id="aa" v-model="view">
    <label for="aa">aa</label>
    <input type="radio" name="aa" value="v-b" id="bb" v-model="view">
    <label for="bb">bb</label>

    <transition name="component-fade" mode="out-in">
    <component v-bind:is="view"></component>

    </transition>
    </div>
    <script>
    new Vue({
    el: '#app',
    data: {
    view: 'v-a'
    },
    components: {
    'v-a': {
    template: '<div>Component A</div>'
    },
    'v-b': {
    template: '<div>Component B</div>'
    }
    }
    })
    </script>
    </body>
    </html>

    相关文章

      网友评论

          本文标题:vue 多组件过渡

          本文链接:https://www.haomeiwen.com/subject/oqddkctx.html