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

I have a question? #3

Closed
happyzhanhan opened this issue Feb 14, 2019 · 6 comments
Closed

I have a question? #3

happyzhanhan opened this issue Feb 14, 2019 · 6 comments

Comments

@happyzhanhan
Copy link

why after I install.my workprogram issues note "Error in mounted hook: "TypeError: Cannot read property 'createTriangle' of undefined"".how can I do for it??

@purestart
Copy link
Owner

purestart commented Feb 15, 2019

you should add ref="canvas" in fabric component and please updated vue-fabric at latest version 0.1.15
such as:
<vue-fabric ref="canvas" :width="width" :height="height"></vue-fabric>

usage:
this.$refs.canvas.createTriangle(params)

@happyzhanhan
Copy link
Author

Error in created hook: "TypeError: Cannot read property 'createTriangle' of undefined".

@purestart
Copy link
Owner

please attach your code !!

@purestart
Copy link
Owner

let options = {
  x: 50,
  y: 120,
  x1: 80,
  y1: 140,
  x2: 30,
  y2: 60,
  color: "#F00",
  drawWidth: 2
}
this.$refs.canvas.createTriangle(options)

@happyzhanhan
Copy link
Author

thank you very much! I found the problem.
eg.
methods:{
init(){
/console.log(this.$refs.canvas);
this.$refs.canvas.createRect({
width: 20,
height: 30,
fillColor: 'blue',
left: 50,
top: 50
});
/
//this.$refs.input1.value="2222";

  console.log(this.$refs);
  console.log(this.$refs.input1);
  console.log(this.$refs.canvas);

},
inputchange(){
  console.log(11111111111);
  console.log(this.$refs);
  console.log(this.$refs.input1);
   console.log(this.$refs.canvas);
}

}

@happyzhanhan
Copy link
Author

need write in mounted(){}.

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