Property or method "swiperOption" is not defined

来源:3-2 滚动条组件

JJJustin

2019-09-06 10:13:01

<template>
<swiper :options="swiperOption">
 <swiper-slide>
  <slot></slot>
 </swiper-slide>
 <div class="swiper-scrollbar" v-if="scrollbar" slot="scrollbar"></div>
</swiper>
</template>
<script>
import {swiper,swiperSlide} from 'vue-awesome-swiper';
export default{
 name: 'MeScroll',
 components: {
  swiper,
  swiperSlide
 },
 props: {
  scrollbar: {
   type: Boolean,
   default: true
  }
 },
 data(){
  return {
   swiperOption: {
    direction: 'vertical',
    slidesPerView: 'auto',
    freeMode: true,
    setWrapperSize: true,
    scrollbar: {
     el: this.scrollbar ? '.swiper-scrollbar' : null,
     hide: true
    }
   }
  }
 }
};
</script>

<style lang="scss" scoped>
.swiper-container{
 overflow: hidden;
 width: 100%;
 height: 100%;
}

.swiper-slide{
 height: auto;
}
</style>

写回答

1回答

好帮手慕言

2019-09-06

同学你好,老师把同学提供的代码放到源码里面测试,是没有问题的。没有报错。

http://img.mukewang.com/climg/5d71fd7300010a4712890426.jpg

如果同学在data里面没有定义swiperOption。那么是会报错的

http://img.mukewang.com/climg/5d71fdc10001e9e209800167.jpg

同学报错是否是没有刷新呢。建议同学刷新一下。

如果帮助到了你,欢迎采纳~祝学习愉快~

0

0 学习 · 10739 问题

查看课程