forked from epicmaxco/vuestic-admin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: billingAddressTab and lineMap reactivity on props change
- Loading branch information
1 parent
6368ece
commit 79997ba
Showing
4 changed files
with
35 additions
and
27 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,7 +40,7 @@ | |
</template> | ||
|
||
<script setup lang="ts"> | ||
import { computed, onMounted, ref, watch } from 'vue' | ||
import { computed, onMounted, reactive, ref, watch } from 'vue' | ||
import { useGlobalConfig } from 'vuestic-ui' | ||
import { useI18n } from 'vue-i18n' | ||
import { lineMapData } from '../../../../data/maps/lineMapData' | ||
|
@@ -50,10 +50,10 @@ | |
const { t } = useI18n() | ||
const emit = defineEmits<{ | ||
(e: 'submit', data: typeof form['value']): void | ||
(e: 'submit', data: typeof form): void | ||
}>() | ||
const form = ref({ | ||
const form = reactive({ | ||
name: 'John Smith', | ||
email: '[email protected]', | ||
address: '93 Guild Street', | ||
|
@@ -77,21 +77,25 @@ | |
const computedStylesTitle = computed(() => ({ color: theme.value.dark })) | ||
watch( | ||
form, | ||
() => { | ||
allowedCitiesList.value = form.value.country | ||
? citiesList.value.filter(({ country }) => country === form.value.country) | ||
() => form.country, | ||
(newCountry, oldCountry) => { | ||
allowedCitiesList.value = form.country | ||
? citiesList.value.filter(({ country }) => country === form.country) | ||
: [...citiesList.value] | ||
if (newCountry !== oldCountry) { | ||
const city = allowedCitiesList.value.find(({ country }) => country === newCountry)?.text || '' | ||
form.city = { text: city } | ||
} | ||
}, | ||
{ deep: true }, | ||
) | ||
onMounted(() => { | ||
allowedCitiesList.value = [...citiesList.value] | ||
}) | ||
function submit() { | ||
emit('submit', form.value) | ||
emit('submit', form) | ||
} | ||
</script> | ||
|
||
|