search

Home  >  Q&A  >  body text

javascript - Ask for a vue related knowledge point

I wrote a module whose function is to slide left to delete

components/swiper-btn.vue

  <v-touch class="list-delete" @swipeleft="onSwipeLeft" @swiperight="onSwipeRight"
           :class="isSlide?'slide-in':'slide-out'">
    <slot></slot>
    <p class="opper">
      <p class="btn-delete" @click="onBtnDel(listIndex)">
        <span class="btn-inner">删除</span>
      </p>
    </p>
  </v-touch>

Now I have a list that needs to use this module. Some of the individual items in the list require this function, and some do not need it.

  <swipe-btn v-if="tabIndex===1">
    <p>列表单项的内容</p>
  </swipe-btn>
  <p v-else>
    <p>列表单项的内容</p>
  </p>

My question is, because in the above code, there are many nests in the "contents of single items in the list", and the two large pieces of code are exactly the same. Is there any way to merge them and write them only once?

某草草某草草2764 days ago734

reply all(1)I'll reply

  • 过去多啦不再A梦

    过去多啦不再A梦2017-05-19 10:41:00

    https://cn.vuejs.org/v2/guide...

    reply
    0
  • Cancelreply