Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Vue warn]: Error in mounted hook: "Error: Konva error: You may only add layers to the stage." #205

Open
rdgbrezolin opened this issue Nov 16, 2022 · 5 comments

Comments

@rdgbrezolin
Copy link

I'm applying the same example from the documentation (link) and it doesn't work.

Example: https://konvajs.org/docs/vue/Shapes.html

Error: [Vue warn]: Error in mounted hook: "Error: Konva error: You may only add layers to the stage."

It seems to me some error with version/installation. I can't run anything related to konva.

"konva": "^8.3.14",
"vue-konva": "^2.1.7",
"vue": "^2.5.22"

@lavrton
Copy link
Member

lavrton commented Nov 16, 2022

Can you make a demo? Like a codesandbox?

@rdgbrezolin
Copy link
Author

rdgbrezolin commented Nov 16, 2022

Yes.

WizardPupilometro.vue:

<template>
  <div>
    <v-stage ref="stage" :config="stageSize">
      <v-layer>
      <v-text :config="{text: 'Some text on canvas', fontSize: 15}"/>
      <v-rect :config="{
          x: 20,
          y: 50,
          width: 100,
          height: 100,
          fill: 'red',
          shadowBlur: 10
        }"
      />
      <v-circle :config="{
          x: 200,
          y: 100,
          radius: 50,
          fill: 'green'
        }"
      />
      <v-line :config="{
        x: 20,
        y: 200,
        points: [0, 0, 100, 0, 100, 100],
        tension: 0.5,
        closed: true,
        stroke: 'black',
        fillLinearGradientStartPoint: { x: -50, y: -50 },
        fillLinearGradientEndPoint: { x: 50, y: 50 },
        fillLinearGradientColorStops: [0, 'red', 1, 'yellow']
      }"/>
      </v-layer>
      <v-layer ref="dragLayer"></v-layer>
    </v-stage>
  </div>
</template>

<script>
const width = window.innerWidth;
const height = window.innerHeight;
let vm = {};
export default {
  data() {
    return {
      stageSize: {
        width: width,
        height: height
      }
    };
  }
};
</script>

Index.js:

import Vue from 'vue';
import App from './App';
import router from './router';

new Vue({
    router,
    el: "#wizardPupilometroRootElement",
    components: { App }
});

Router.js:

import Vue from 'vue';
import VueRouter from 'vue-router';
import WizardPupilometro from './components/WizardPupilometro.vue';
import VueKonva from 'vue-konva';

Vue.use(VueRouter);
Vue.use(VueKonva);

let router = new VueRouter({
    routes: [
        {
            path: '/',
            name: 'WizardPupilometro',
            component: WizardPupilometro,
            props: true,
        },
    ]
});

export default router;

@rdgbrezolin
Copy link
Author

image

@rdgbrezolin
Copy link
Author

@lavrton Can you help me? I can't run any examples from konva.

@lavrton
Copy link
Member

lavrton commented Dec 17, 2022

I need a small demo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants