你搞定了吗?我正在尝试加载一个 pixi 对象,如下所示...没有错误,但我的目标画布元素中没有任何内容?
<template>
<div class="connections">
<canvas id="pixi"></canvas>
</div>
</template>
<script>
import { mapState } from 'vuex'
import * as PIXI from 'pixi.js'
var canvas = document.getElementById('pixi')
export default {
name: 'ConnectionsLayer',
computed: mapState({
toolmode: (state) => state.ui.mode,
}),
data() {
return {
app: new PIXI.Application({
width: window.innerWidth,
height: window.innerHeight,
antialias: true,
transparent: true,
view: canvas,
}),
}
},
methods: {},
mounted() {
let graphics = new PIXI.Graphics()
graphics.x = this.app.renderer.width / 2
graphics.y = this.app.renderer.width / 2
graphics.lineStyle(0)
graphics.beginFill(0xde3249, 1)
graphics.drawCircle(100, 250, 50)
graphics.endFill()
graphics.lineStyle(0)
graphics.beginFill(0xde3249, 1)
graphics.drawCircle(300, 250, 50)
graphics.endFill()
graphics.lineStyle(2, 0xffffff, 1)
graphics.moveTo(100, 250)
graphics.lineTo(300, 250)
graphics.lineStyle(2, 0xffffff, 1)
graphics.moveTo(0, 0)
this.app.stage.addChild(graphics)
},
}
</script>