[Vuejs]-Translations of vue-dataset in Vue 3 script setup configuration

0👍

To adapt the vue-dataset to a Composition API format in Vue 3 and provide translation, create a wrapper component that provides the translation:

<template>
  <Dataset :datasetI18n="datasetI18n" v-bind="$attrs" v-on="$listeners" />
</template>

<script setup>
import { ref, onMounted } from 'vue';
import { Dataset } from 'vue-dataset'

const datasetI18n = ref({
  // Add translations here
});

onMounted(() => {
  import('vue-dataset').then(module => {
    Dataset = module.Dataset;
  });
});
</script>

This wrapper uses dynamic import to load vue-dataset only when used. When using this wrapper, the vue-dataset component will load with provided translations.

Hope this helps!

Leave a comment