Comments (7)
@markyun Vue 2.0 里 v-ref:swipe
不能这么写了,要写成 ref="swipe"
。
from vue-swipe.
from vue-swipe.
@nigulasikk vue-swipe 组件本身有 next
和 prev
方法,可以像这样调用它们:
<template>
<swipe v-ref:swipe>
...
</swipe>
<button @click="next">下一张</button>
<button @click="prev">上一张</button>
</template>
<script>
export default {
methods: {
next() {
this.$refs.swipe.next();
},
prev() {
this.$refs.swipe.prev();
}
}
};
</script>
from vue-swipe.
这个方法好像不管用....
from vue-swipe.
@markyun 请给出代码和 vue-swipe 的版本号。
from vue-swipe.
#版本:"vue-swipe": "^2.0.0"
#代码:
<template>
<div class="main">
<swipe v-ref:swipe class="demo-swipe">
<swipe-item class="slide1"><img src="./assets/img/1.jpg" class="swipe-img" ></swipe-item>
<swipe-item class="slide2"><img src="./assets/img/2.jpg" class="swipe-img" ></swipe-item>
</swipe>
<button @click="next">下一张</button>
<button @click="prev">上一张</button>
</div>
</template>
<script>
export default {
methods: {
next () {
console.log('next!')
this.$refs.swipe.next()
},
prev () {
this.$refs.swipe.prev()
}
}
}
</script>
功能正常显示,但页面提示:Cannot read property 'next' of undefined
thanks
from vue-swipe.
@Leopoldthecoder 果然是这个问题,对Vue的API还不太熟,感谢
from vue-swipe.
Related Issues (20)
- 能不能在goto函数中加一个参数,决定是否在切换时使用动画。 HOT 1
- 使用goto跳转两个以上页面之后,除了首尾页,其他页会出现swipe-item上绑定click事件无法触发的问题。 HOT 3
- 在轮播内横向滑动后再纵向滑动极长的距离,动画卡住 HOT 4
- 运行报错了。。 HOT 3
- 如何根据图片的高度来改变其高度啊。。。
- defaultIndex设置之后为啥不起作用啊!!! HOT 1
- 整个页面的左右滑动 HOT 1
- sync with npm HOT 1
- 使用goto切换到某一页会出现一会儿的页面空白的现象 HOT 3
- 滑动图片的时候,轮播图轮播到下一长图时间不会减去我滑动所用的时间,造成视觉上的差异
- Clickable indicators
- [Vue warn]: Error in nextTick: "TypeError: Cannot read property '$options' of undefined" HOT 1
- 在短时间连续调用goto会导致slide重合 HOT 1
- continuous 为 false 时,两张图片以上就会重复闪动
- 建议swipe组件加入垂直方向滚动
- change
- 改变 :auto 无效
- vue-swipe没有网格模式么(多栏轮播切换)
- 升级 iOS 13 之后 SwipeItem 内部链接要点两次才能触发 HOT 3
- auto height
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vue-swipe.