Est-ce que quelqu'un a utilisé ce composant avec Vue?Impossible d'accéder à l'attribut canvas personnalisé dans Vue
https://www.npmjs.com/package/aframe-draw-component.
Je veux utiliser l'utilisation avancée avec "aframe-draw-component". cela fonctionne avec le html brut mais pas vue.js. codepen example
// html
<a-scene fog="type: exponential; color:#000">
<a-sky acanvas rotation="-5 -10 0"></a-sky>
</a-scene>
// js
const chars = 'ABCDEFGHIJKLMNOPQRWXYZ'.split('')
const font_size = 8
AFRAME.registerComponent("acanvas", {
dependencies: ["draw"],
init: function(){
console.log(this.el.components)
this.draw = this.el.components.draw // get access to the draw component
this.draw.canvas.width = '512'
this.draw.canvas.height = '512'
this.cnvs = this.draw.canvas
const columns = this.cnvs.width/font_size
this.drops = []
for (let x = 0; x < columns; x++) {
this.drops[x] = 1
}
this.ctx = this.draw.ctx
},
tick: function() {
this.ctx.fillStyle = 'rgba(0,0,0,0.05)'
this.ctx.fillRect(0, 0, this.cnvs.width, this.cnvs.height)
this.ctx.fillStyle = '#0F0'
this.ctx.font = font_size + 'px helvetica'
for(let i = 0; i < this.drops.length; i++) {
const txt = chars[Math.floor(Math.random() * chars.length)]
this.ctx.fillText(txt, i * font_size, this.drops[i] * font_size)
if(this.drops[i] * font_size > this.cnvs.height && Math.random() > 0.975) {
this.drops[i] = 0 // back to the top!
}
this.drops[i] = this.drops[i] + 1
}
this.draw.render()
}
})
Peu importe où je mets dans le composant Vue, je reçois cette erreur:
App.vue B405: 124 Uncaught (en promesse) TypeError: Impossible 'toile' lire la propriété de non définie à NewComponent.init (eval à
Il ne peut pas trouver la dépendance personnalisée « tirer ».
quelqu'un peut me aider?
Merci.
Veuillez fournir un code que vous avez essayé afin que quelqu'un puisse vous aider. – Cobaltway