Skip to content

Instantly share code, notes, and snippets.

@wxk6b1203
Created October 9, 2020 18:59
Show Gist options
  • Save wxk6b1203/66914efbb633897655f525af9e4f3140 to your computer and use it in GitHub Desktop.
Save wxk6b1203/66914efbb633897655f525af9e4f3140 to your computer and use it in GitHub Desktop.
Vue 3.0.0 qiz reproduction of "Boolean to default false"
<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