报错 'update' of undefined
<template>
<swiper :options="swiperOption" ref="swiper">
<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
},
data1:{
type:[Array,Object] // 数组或者对象
}
},
data(){
return{
swiperOption:{
direction: 'vertical',
slidesPerView: 'auto',
freeMode: true,
setWrapperSize: true,
scrollbar: {
el: this.scrollbar ? '.swiper-scrollbar' : null,
hide: true
}
}
}
},
watch:{
data1(){
this.update()
}
},
methods:{
update(){
this.$refs.swiper && this.$refs.swiper.swiper.update() // 更新滚动条,用swiper提供的api
}
}
}
</script>
<style lang="scss" scoped>
.swiper-container{
overflow: hidden;
width: 100%;
height: 100%;
}
.swiper-slide{
height: auto;
}
</style>
----------------------------------------------------
------------------------
老师这是哪里不对
正在回答
同学你好,应该是版本的问题,老师授课时使用的版本是3.1.1。 同学修改后项目可以正常使用就可以了。
不过同学目前在学习阶段,推荐与老师讲解的版本保持一致会更好哦。示例:使用如下命令安装
npm install vue-awesome-swiper@3.1.1 -D
祝学习愉快~
- 参与学习 人
- 提交作业 239 份
- 解答问题 10739 个
本阶段带你深入前端开发的肌理,通过ES6基础知识和前端主流高级框架的学习,助你快速构建企业级移动webAPP应用,进入职场的终极battle
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星