Переключение Vue JS на основе связанного класса - упрощение вверх и вниз

взгляните на свой импорт. Eclipse импортирован автоматически java.util.Timer. Измените это на javax.swing.Timer, и вы должны быть на вашем пути.

1
задан Jessica 17 January 2019 в 06:22
поделиться

2 ответа

Вы можете отказаться от использования v-if и v-show, просто изменив значение высоты. Конечный результат намного плавнее.

Имейте в виду, что изменение высоты элементов является дорогостоящей операцией, поскольку браузер должен перерисовывать все, на что влияет высота элементов.

new Vue({
  el: '#app',
  data: () => ({
    more: false,
    height: '80px'
  }),
  computed: {
    mode() {
      return this.more ? 'out-in' : 'in-out'
    }
  }
})
#app p:nth-of-type(2) {
    height: 0;
    overflow: hidden;
    transition: 1s;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="app">

  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. </p>
    <p :style="[more ? { height } : {}]">
      Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum</p>
  <button @click="more = !more">{{ more ? 'Show Less' : 'Show More' }}</button>
</div>

0
ответ дан DigitalDrifter 17 January 2019 в 06:22
поделиться

Я сделал один пример. Проверьте это один раз. Это может помочь. (Вы упомянули 100% в max-height и в начале max-height, вы упомянули 51px, что может быть проблемой для неперехода. Поддерживайте оба в px или%)

<template>
<div id="app">
    <div class="paragraph" :class="{showmore:checkStatus}">
       <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry.             Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
    It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).
    Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
    It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).

  </p>
</div>
<button @click="changeData">{{ readStatus }}</button>
  </div>
  </template>

<script>
  export default {
  name: 'App',
  data:function(){
return {
  readStatus:'readmore',
  checkStatus:false
}
},
methods:{
changeData:function(){

  if(this.readStatus=='readmore'){
    this.readStatus='readless';
    this.checkStatus=true;
  }else{
    this.readStatus='readmore';
    this.checkStatus=false;
  }
  }
  }
 }
  </script>

<style scoped>
  .paragraph {
max-height: 100px;
overflow: hidden;
transition: max-height 2s;

 }
 .paragraph p{
  color: black;
 }
 .showmore{
max-height: 500px;
overflow: auto;
 }
</style>
0
ответ дан PALLAMOLLA SAI 17 January 2019 в 06:22
поделиться
Другие вопросы по тегам:

Похожие вопросы: