NativeScript / canvas

Apache License 2.0
88 stars 18 forks source link

Not working on NSVue #13

Closed luiguild closed 3 years ago

luiguild commented 3 years ago
<template lang="pug">
Page(
  actionBarHidden="true"
)
  GridLayout(
    rows="*",
    columns="*"
  )
    Canvas(
      id="canvas"
      width="100%"
      height="100%"
      ready="doCanvasStart"
    )
</template>

<script>
import Vue from 'nativescript-vue'

Vue.registerElement(
  'Canvas',
  () => require('@nativescript/canvas')
    .Canvas
)

export default {
  name: 'DesignSandbox',
  components: {},
  data: () => ({
    canvas: null,
    ctx: null
  }),
  methods: {
    doCanvasStart (args) {
      console.log('canvas ready')
      this.canvas = args.object
      console.log(this.canvas)
      this.ctx = this.canvas.getContext('2d')
      this.ctx.fillStyle = 'green'
      this.ctx.fillRect(10, 10, 150, 100)
    }
  }
}
</script>
{NSVue (Vue: 2.6.11 | NSVue: 2.7.1)} -> CreateElement(canvas)
JS: TypeError: Could not load view for: nativecanvas. TypeError: Object(...) is not a function TypeError: Object(...) is not a function
JS:     at Module.../node_modules/@nativescript/canvas/Canvas/common.js (file: src\packages\canvas\Canvas\common.ts:9:9)
triniwiz commented 3 years ago

Thanks for reporting this can you share which platform is this and your {N} version

triniwiz commented 3 years ago

Should be fixed in the latest test an LMK feel free to reopen