I have div and I want to change its position dynamically using VueJS app. I have variable x in data function and I want to assign it to top. this is the code I write but it dosn't work in template tag:
<template>
<div id="squar" v-if="showSquar" :style="{top: x}" @click="countClicks">
click here
</div>
</template>
and in style tag:
#squar{
width: 100px;
height: 100px;
border-radius: 5px;
background: rgb(0,70,40,0.8);
color: white;
text-align: center;
vertical-align: middle;
line-height: 100px;
position: absolute;
}
the component that I work in isn't the App component
:style="{top: x}"to:style="`top: ${x}`"you may also need to include!important