Home  >  Q&A  >  body text

javascript - using turn.js in vue

Use turnjs in the vue component as a plug-in for turning books.
First introduce the corresponding jquery in index.html, and then in The component is as follows:

import turn from 'jsPath/lib/turn.min'
export default {
  mounted() {
    this.$nextTick(() => {
      $('.flipbook').turn({
        width: 922,
        height: 600,
        elevation: 50,
        gradients: true,
        autoCenter: true
      });
    });
  }
}

Sequential reference should be no problem, but the turn function cannot be called, and the console reports an error, TypeError: $(...).turn is not a function.
Has anyone used this plug-in? What? What causes this problem? How to solve it?

女神的闺蜜爱上我女神的闺蜜爱上我2636 days ago1963

reply all(1)I'll reply

  • 代言

    代言2017-07-05 10:57:38

    It is estimated that it is caused by your quoting jquery. I have had similar problems before when I quoted jquery’s third-party plug-in. Try exposing jquery globally.
    main.js in:

    import jquery  from 'jquery';
    global.jquery = global.$ = jquery;

    reply
    0
  • Cancelreply