Created
October 9, 2020 18:59
-
-
Save wxk6b1203/66914efbb633897655f525af9e4f3140 to your computer and use it in GitHub Desktop.
Vue 3.0.0 qiz reproduction of "Boolean to default false"
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> | |
<a-modal v-model:visible="onShow"> </a-modal> | |
</template> | |
<script lang="ts"> | |
// import { Options, Vue } from "vue-class-component"; | |
// @Options({ | |
// props: { | |
// show: Boolean, | |
// }, | |
// emits: ["update:show"], | |
// }) | |
// export default class Settings extends Vue { | |
// show!: boolean; | |
// public get onShow(): boolean { | |
// return this.show; | |
// } | |
// public set onShow(v: boolean) { | |
// this.$emit("update:show", v); | |
// } | |
// } | |
import { computed, defineComponent } from "vue"; | |
export default defineComponent({ | |
name: "Settings", | |
props: { | |
show: { | |
type: Boolean, | |
default: false, // TODO: wait for v3 to fix the default boolean to false problem. | |
}, | |
}, | |
setup(props, { emit }) { | |
const onShow = computed({ | |
get: () => { | |
return props.show; | |
}, | |
set: (val: boolean) => { | |
emit("update:show", val); | |
}, | |
}); | |
return { | |
onShow, | |
}; | |
}, | |
}); | |
</script> | |
<style> | |
</style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment