Currently, I am attempting to incorporate setInterval with my moveImage function in order to modify the position of an image. Here is a snippet of my code:
<template>
<div class="randImg">
<img v-bind:style="{top: imgTop + 'px', left: imgLeft + 'px',height: imgHeight + 'px', width: imgWidth + 'px'}"
class="image" v-bind:src="vue">
</div>
</template>
<script>
const vue = require("../assets/images/vue.png");
export default {
name: "randImg",
data() {
return {
vue,
imgTop: 0,
imgLeft: 0,
imgHeight: 64,
imgWidth: 64,
changeInterval: 1000
}
},
created() {
setInterval(this.moveImage(), this.changeInterval);
},
computed: {
moveImage() {
this.imgTop = Math.round(Math.random() * (screen.height - this.imgHeight));
this.imgLeft = Math.round(Math.random() * (screen.width - this.imgWidth));
}
}
}
</script>
Unfortunately, while using vue.js, I encountered an error message stating "this.moveImage is not a function." Can someone please assist me in resolving this issue?