|
20 | 20 | </nav> |
21 | 21 | </template> |
22 | 22 |
|
23 | | -<script> |
| 23 | +<script setup> |
24 | 24 | import Collapse from '../collapse/Collapse.vue'; |
| 25 | +import { computed, onMounted, ref, watch } from 'vue'; |
25 | 26 |
|
26 | | -export default { |
27 | | - components: { Collapse }, |
28 | | - props: { |
29 | | - modelValue: Boolean, |
30 | | - fluid: { |
31 | | - type: Boolean, |
32 | | - default: true, |
33 | | - }, |
34 | | - fixedTop: Boolean, |
35 | | - fixedBottom: Boolean, |
36 | | - staticTop: Boolean, |
37 | | - inverse: Boolean, |
38 | | - }, |
39 | | - emits: ['update:modalValue'], |
40 | | - data() { |
41 | | - return { |
42 | | - show: false, |
43 | | - }; |
44 | | - }, |
45 | | - computed: { |
46 | | - navClasses() { |
47 | | - return { |
48 | | - navbar: true, |
49 | | - 'navbar-default': !this.inverse, |
50 | | - 'navbar-inverse': this.inverse, |
51 | | - 'navbar-static-top': this.staticTop, |
52 | | - 'navbar-fixed-bottom': this.fixedBottom, |
53 | | - 'navbar-fixed-top': this.fixedTop, |
54 | | - }; |
55 | | - }, |
56 | | - }, |
57 | | - watch: { |
58 | | - modelValue(v) { |
59 | | - this.show = v; |
60 | | - }, |
61 | | - }, |
62 | | - mounted() { |
63 | | - this.show = !!this.modelValue; |
64 | | - }, |
65 | | - methods: { |
66 | | - toggle() { |
67 | | - this.show = !this.show; |
68 | | - this.$emit('update:modalValue', this.show); |
69 | | - }, |
70 | | - }, |
71 | | -}; |
| 27 | +const props = defineProps({ |
| 28 | + modelValue: Boolean, |
| 29 | + fluid: { type: Boolean, default: true }, |
| 30 | + fixedTop: Boolean, |
| 31 | + fixedBottom: Boolean, |
| 32 | + staticTop: Boolean, |
| 33 | + inverse: Boolean, |
| 34 | +}); |
| 35 | +const emit = defineEmits(['update:modalValue']); |
| 36 | +const show = ref(false); |
| 37 | +const navClasses = computed(() => ({ |
| 38 | + navbar: true, |
| 39 | + 'navbar-default': !props.inverse, |
| 40 | + 'navbar-inverse': props.inverse, |
| 41 | + 'navbar-static-top': props.staticTop, |
| 42 | + 'navbar-fixed-bottom': props.fixedBottom, |
| 43 | + 'navbar-fixed-top': props.fixedTop, |
| 44 | +})); |
| 45 | +
|
| 46 | +watch( |
| 47 | + () => props.modelValue, |
| 48 | + (v) => { |
| 49 | + show.value = v; |
| 50 | + } |
| 51 | +); |
| 52 | +
|
| 53 | +onMounted(() => { |
| 54 | + show.value = !!props.modelValue; |
| 55 | +}); |
| 56 | +
|
| 57 | +function toggle() { |
| 58 | + show.value = !show.value; |
| 59 | + emit('update:modalValue', show.value); |
| 60 | +} |
72 | 61 | </script> |
0 commit comments