Skip to content

Use translation as prop default fallback with script setup #1012

Answered by dpschen
dpschen asked this question in Q&A
Discussion options

You must be logged in to vote

Okay not sure why it didn't work out in the first place, but I got it now running like this:

<script setup>
import {useI18n} from 'vue-i18n'

const props = defineProps({
	label: {
		type: String,
		default() {
			const {t} = useI18n()
			return t('fallback-label');
		},
	},
})
</script>

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by dpschen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant