Giter Site home page Giter Site logo

Comments (7)

Leopoldthecoder avatar Leopoldthecoder commented on August 28, 2024 1

@markyun Vue 2.0 里 v-ref:swipe 不能这么写了,要写成 ref="swipe"

from vue-swipe.

furybean avatar furybean commented on August 28, 2024

@Leopoldthecoder

from vue-swipe.

Leopoldthecoder avatar Leopoldthecoder commented on August 28, 2024

@nigulasikk vue-swipe 组件本身有 nextprev 方法,可以像这样调用它们:

<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.

markyun avatar markyun commented on August 28, 2024

这个方法好像不管用....

from vue-swipe.

Leopoldthecoder avatar Leopoldthecoder commented on August 28, 2024

@markyun 请给出代码和 vue-swipe 的版本号。

from vue-swipe.

markyun avatar markyun commented on August 28, 2024

#版本:"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.

markyun avatar markyun commented on August 28, 2024

@Leopoldthecoder 果然是这个问题,对Vue的API还不太熟,感谢

from vue-swipe.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.