im trying to use v-if to render 2 buttons in different containers on page, depending on screen size is there way how to change parent of items in @media or way how to use screen size in v-if condition?
i tried
<div v-if="window.innerWidth < 860">
<!-- Some code -->
</div>
but it throws me "TypeError: Cannot read properties of undefined (reading 'innerWidth')"
(when i use just media query, there appears bug with radio btns, when they needs 2 clicks to get :checked styles) when i tried @media, in fact there was 4 buttons, that binded to 2 variables
<!-- button code -->
<label>
<input type="radio" name="month-season" id="month" value="month" v-model="monthSeason">
<null-button>
<img src="../assets/green-smile.png" alt="#" id="month-icon">
text
</null-button>
</label>
<!-- null-button -->
<div class="parent">
<div class="container">
<slot></slot>
</div>
<div>
<!-- styles for button -->
<style>
.month-season {
text-align: right;
label {
.container {
color: rgba(45, 206, 137, 1);
background: white;
img {
margin: 0 4px 0 0;
}
}
input:checked + .parent .container {
background: rgba(45, 206, 137, 1);
color: white;
img {
filter: brightness(1000%);
}
}
input {
appearance: none;
}
}
}
</style>
Error message when I use window.innerWidth