Vue 实现展开折叠效果
效果参见:https://segmentfault.com/q/1010000011359250/a-1020000011360185
上述链接中,大佬给除了解决方法,再次进行总结,方便以后使用。
除了使用jQuery的方式实现上述效果,同样可以在Vue实现,下面是解决办法:
1、创建collapse.js文件
const elTransition =
"0.3s height ease-in-out, 0.3s padding-top ease-in-out, 0.3s padding-bottom ease-in-out";
const Transition = {
"before-enter"(el) {
el.style.transition = elTransition;
if (!el.dataset) el.dataset = {};
el.dataset.oldPaddingTop = el.style.paddingTop;
el.dataset.oldPaddingBottom = el.style.paddingBottom;
el.style.height = 0;
el.style.paddingTop = 0;
el.style.paddingBottom = 0;
},
enter(el) {
el.dataset.oldOverflow = el.style.overflow;
if (el.scrollHeight !== 0) {<