简体   繁体   English

Vue.js转换在Laravel Blade + Sass中不起作用

[英]Vue.js transitions not working in Laravel Blade + Sass

My Google search didn't come up with any answer to is this expected behavior or am I doing something wrong. 我的Google搜索没有针对这种预期行为或我做错了任何答案。

My HTML: 我的HTML:

<a v-on:click="showInformation = !showInformation">Show / Hide</a>
<transition name="fade">
    <p class='further-info' v-if="!showInformation">Lorem ipsum dolor.</p>
</transition>

EDIT: Just found out that it works like this: 编辑:刚发现它是这样的:

<transition name="fade">
    <div v-if="!showInformation">
        <p class='further-info'>Lorem ipsum dolor</p>
    </div>
</transition>

This is not documented in the Vue.js documentation and it's clearly shown that it should work as the first example. Vue.js文档中未对此进行记录,并且清楚地表明它应该作为第一个示例。 Is this expected in my case? 就我而言,这是预期的吗?

My SASS: 我的SASS:

.fade-enter-active, .fade-leave-active
    transition: opacity .5s

.fade-enter, .fade-leave-to
    opacity: 0

Pretty straight forward, but I may be doing something wrong. 很简单,但是我可能做错了什么。 Whenever I click the button the p shows and hides correctly, but without any transition effect. 每当我单击按钮时, p正确显示和隐藏,但没有任何过渡效果。

Using: 使用:

Laravel 5.7.9
Vue.js 2.9.6 (with ES6)
Sass 1.14.2 (but not relevant since it complies the transition code correctly)
The HTML file is written a blade template file

You should change the v-if to a v-show. 您应该将v-if更改为v-show。 This way the element exists in the page even though it's not displayed. 这样,即使元素未显示,它也存在于页面中。

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

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