pcpuma_unam_operador/components/inputs/InputRecordar.vue
2022-09-22 13:24:31 -05:00

36 lines
823 B
Vue

<template>
<b-field class="mb-0 pb-0 mt-3">
<b-checkbox v-model="recordar">Recordar</b-checkbox>
</b-field>
</template>
<script>
export default {
props: {
nombreVariable: { typeof: String, required: true, default: '' },
variablePadre: { typeof: Number, required: true, default: 0 },
},
data: () => {
return { recordar: false }
},
watch: {
recordar() {
if (!this.recordar) localStorage.removeItem(this.nombreVariable)
else {
if (this.variablePadre)
localStorage.setItem(this.nombreVariable, this.variablePadre)
}
},
variablePadre() {
if (this.recordar)
localStorage.setItem(this.nombreVariable, this.variablePadre)
},
},
created() {
if (this.variablePadre) this.recordar = true
},
}
</script>
<style scoped></style>