Last active
March 27, 2019 18:53
-
-
Save trezy/10f80c7befeb2f409e5d4ecd4de93c14 to your computer and use it in GitHub Desktop.
Weird Nuxt SSR issue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div class="collapsable"> | |
<input | |
:id="`${id}::collapsable-control`" | |
:name="[`${group}`]" | |
:type="[`${group ? 'radio' : 'checkbox'}`]" /> | |
<label | |
v-on:click="handleClick" | |
:for="`${id}::collapsable-control`"> | |
<slot name="control" /> | |
</label> | |
<div :class="`collapsable-child ${childClasses}`"> | |
<slot name="child" /> | |
</div> | |
</div> | |
</template> | |
<script> | |
import uuid from 'uuid/v4' | |
export default { | |
methods: { | |
handleClick: ({ target }) => { | |
const controlID = target.getAttribute('for') | |
const controlElement = document.querySelector(`[id='${controlID}']`) | |
// eslint-disable-next-line | |
console.log('controlElement', controlElement) | |
if (controlElement && controlElement.checked) { | |
controlElement.checked = false | |
} | |
}, | |
}, | |
props: { | |
childClasses: { | |
default: null, | |
type: String, | |
}, | |
group: { | |
default: '', | |
type: String, | |
}, | |
id: { | |
default: () => uuid(), | |
type: String, | |
}, | |
}, | |
} | |
</script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<Collapsable> | |
<template v-slot:control> | |
Label | |
</template> | |
<template v-slot:child> | |
Content | |
</template> | |
</Collapsable> | |
</template> | |
<script> | |
import Collapsable from './Collapsable.vue' | |
export default { | |
components: { | |
Collapsable, | |
}, | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment