How to listen for changes in the script #126
Unanswered
Yanren1225
asked this question in
Q&A
Replies: 1 comment
-
<script setup lang="ts">
import { useI18n } from 'vue-i18n'
import { ref, watch, watchEffect } from 'vue'
const { t, locale } = useI18n()
const featureList = ref([
[t('main.solution.feature.1')],
[t('main.solution.feature.2'), t('main.solution.feature.3')],
[
t('main.solution.feature.4'),
t('main.solution.feature.5'),
t('main.solution.feature.6'),
],
[t('main.solution.feature.7'), t('main.solution.feature.8')],
])
watch(locale, () => {
featureList.value = [
[t('main.solution.feature.1')],
[t('main.solution.feature.2'), t('main.solution.feature.3')],
[
t('main.solution.feature.4'),
t('main.solution.feature.5'),
t('main.solution.feature.6'),
],
[t('main.solution.feature.7'), t('main.solution.feature.8')],
]
})
</script> I can only think of this |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I get the language data in the script like this
After that I will use v-for in the template to do something, But the problem is that this part doesn't change after switching Locale, so all I can think of is to listen to the locale in watch and reassign it. Anyone have a better idea?
Beta Was this translation helpful? Give feedback.
All reactions