鍍金池/ 問答/HTML/ vue的render中如何實(shí)現(xiàn)v-show

vue的render中如何實(shí)現(xiàn)v-show

用template中寫完, 通過isShow可以實(shí)現(xiàn)動(dòng)畫, 但是為什么我用render實(shí)現(xiàn)的就不好使了呢?
請(qǐng)問我的render的問題在哪里?

切換有動(dòng)畫

  <transition name="fadeUp">
      <span v-show="isShow" class="atom-popper">
          <slot>{{content}}</slot>
      </span>
  </transition>

切換無動(dòng)畫

   render(h) {
        return h(
            'transition',
            {
                attrs: { name: 'fadeUp' }
            }, [
                h(
                    'span',
                    {
                        class: ['atom-popper'],
                        style: { display: this.isShow ? undefined : 'none' }
                    },
                    [this.content || this.$slots.default]
                )
            ]
        );
    },
回答
編輯回答
陌南塵

不是讓他 在樣式上切換 display none block.
據(jù)我推想:
v-show 不是簡(jiǎn)簡(jiǎn)單單給 虛擬dom 加上 style display none 或 block, 里面八成 有個(gè)鉤子 通知 tran 這個(gè)組件。 son 要 顯示 隱藏, farther 你有何動(dòng)作。

2018年6月13日 17:02
編輯回答
浪蕩不羈
style: { display: this.isShow ? 'inline' : 'none' }
2018年6月17日 14:56