We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
今天偶然发现,在Vue中使用插槽slot,是无法通过v-show控制slot的显示的,来看代码
Vue.component('fade', { props: ['show'], template: ` <transition @before-enter="handleBeforeEnter" @enter="handleEnter"> <slot v-show="show"></slot> </transition> `, methods: { handleBeforeEnter: function(el) { el.style.color = 'red' }, handleEnter: function(el, done) { setTimeout(() => { el.style.color = 'green' done() }, 2000) } } })
这是随便写的一个封装动画组件,如果在slot标签上使用v-show,程序功能是无法实现的,必须要改成v-if。
原因是这样的,slot实际上是一个抽象元素,有点类似template,本质上并不是一个元素。而v-show是通过控制元素的display来进行显示隐藏的,slot本质上并不是元素,所以压根也就不会有display 这个css属性。
所以,slot的显示隐藏,还真得使用v-if。
The text was updated successfully, but these errors were encountered:
No branches or pull requests
今天偶然发现,在Vue中使用插槽slot,是无法通过v-show控制slot的显示的,来看代码
这是随便写的一个封装动画组件,如果在slot标签上使用v-show,程序功能是无法实现的,必须要改成v-if。
原因是这样的,slot实际上是一个抽象元素,有点类似template,本质上并不是一个元素。而v-show是通过控制元素的display来进行显示隐藏的,slot本质上并不是元素,所以压根也就不会有display 这个css属性。
所以,slot的显示隐藏,还真得使用v-if。
The text was updated successfully, but these errors were encountered: