J
J
Junior Development2021-03-04 11:13:02
Vue.js
Junior Development, 2021-03-04 11:13:02

How to resolve error: Cannot read property 'created' of undefined Vue.js?

I connect this plugin
https://github.com/river-lee/vue-fullpage#options

6040967fc92a4574743232.jpeg

main.js

import { createApp } from 'vue'
import 'animate.css'
import 'fullpage-vue/src/fullpage.css'
import VueFullpage from 'fullpage-vue'

import App from './App.vue'

const app = createApp(App);
app.use(VueFullpage).mount('#app')


app.js
<template>

  <div class="fullpage-container">
    <div class="fullpage-wp" v-fullpage="opts" ref="example">
      <div class="page-1 page">
        <p class="part-1" v-animate="{value: 'bounceInLeft'}">fullpage-vue</p>
      </div>
      <div class="page-2 page">
        <p class="part-2" v-animate="{value: 'bounceInRight'}">fullpage-vue</p>
      </div>
      <div class="page-3 page">
        <p class="part-3" v-animate="{value: 'bounceInLeft', delay: 0}">fullpage-vue</p>
        <p class="part-3" v-animate="{value: 'bounceInRight', delay: 600}">fullpage-vue</p>
        <p class="part-3" v-animate="{value: 'zoomInDown', delay: 1200}">fullpage-vue</p>
      </div>
    </div>
    <button @click="moveNext">next</button>
  </div>

</template>
<style>
.fullpage-container {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
}
</style>
<script>
export default {
  name: 'App',

  data() {
    return {
      opts: {
        start: 0,
        dir: 'v',
        duration: 500,
      }
    }
  },
  methods:{
    moveNext(){
      this.$refs.example.$fullpage.moveNext(); //Move to the next page
    }
  },

}
</script>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2021-03-04
@jun_dev

I connect this plugin
https://github.com/river-lee/vue-fullpage#options

We follow the link, we see that this plugin
based on [email protected]

Then we look at the code you showed:
import { createApp } from 'vue'

From the very first line, we understand that vue 3 is being used.
Here it becomes obvious that four options are available to you:
  1. Downgrade vue version being used
  2. Wait for the plugin author to make a version for vue 3
  3. Fork the repository, finish it under vue 3 yourself
  4. Stop using this plugin, find another one

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question