简体   繁体   English

为什么转换没有注册为 html 中的元素?

[英]Why isn't transition getting registered as an element in html?

<template>
<header>
<nav class="container">
    <div class="branding">
        <router-link class="header" :to="{name : 'Home'}">>FireBlogs</router-link>
    </div>
    <div class="nav-links">
        <ul>
            <router-link class="link" to="#">Home</router-link>
            <router-link class="link" to="#">Blogs</router-link>
            <router-link class="link" to="#">Create Post</router-link>
            <router-link class="link" to="#">Login/Register</router-link>
        </ul>
    </div>
</nav>
<menuIcon class="menu-icon" />
    <transition name="mobile-nav" id="mobile-nav">
        <ul>
            <router-link class="link" to="#">Home</router-link>
            <router-link class="link" to="#">Blogs</router-link>
            <router-link class="link" to="#">Create Post</router-link>
            <router-link class="link" to="#">Login/Register</router-link>
        </ul>
    </transition>
</header>
</template>

In this vueJS code I have some elements inside the transition tag, but when I inspect the web page I can only see this: Console Image here I wish to style the transition tag as a whole using CSS.在这个 vueJS 代码中,我在转换标签中有一些元素,但是当我检查网页时,我只能看到: Console Image here I wish to style the transition tag as a whole using CSS。 Can somebody help me figure this out?有人可以帮我解决这个问题吗?

Adding an answer since this is getting some upvotes:添加一个答案,因为这得到了一些支持:

transition elements do not create a DOM element, they define transitions/changes of states to elements within the tag. transition元素不创建 DOM 元素,它们定义标签元素的状态转换/更改。

To create a DOM element that can be targeted with CSS, you can use TransitionGroup and then use the tag property to render a wrapping element:要创建一个可以使用 CSS 定位的 DOM 元素,您可以使用TransitionGroup ,然后使用tag属性来呈现一个包装元素:

<TransitionGroup tag="div">{stuff here}</TransitionGroup>

If you don't want to create another element, but keep the transition element, you can use the parent element to style.如果不想创建另一个元素,但保留transition元素,则可以使用父元素来设置样式。

header > ul { styles here }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM