Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to avoid "Component is declared but its value is never read." when I use Vue3 setup syntax?

<template>
  <ConfigProvider :locale="getAntdLocale">
    <AppProvider>
      <RouterView />
    </AppProvider>
  </ConfigProvider>
</template>
<script lang="ts" setup>
  import { ConfigProvider } from 'ant-design-vue';
  import { AppProvider } from '/@/components/Application';
  import { useTitle } from '/@/hooks/web/useTitle';
  import { useLocale } from '/@/locales/useLocale';

  // support Multi-language
  const { getAntdLocale } = useLocale();

  // Listening to page changes and dynamically changing site titles
  useTitle();
</script>

Vetur shows this warning:

'ConfigProvider' is declared but its value is never read.Vetur(6133)

'getAntdLocale' is declared but its value is never read.Vetur(6133)

It seems the template can't read the script with setup syntax variable. How can I avoid this warning?

like image 207
liuestc Avatar asked Dec 22 '25 08:12

liuestc


1 Answers

Vetur has no support for script setup yet - it is planned for v0.37.0 (current version is 0.34.1)

As of now, Volar is better choice for using script setup and TS and is recommended even by Evan You (Vue creator). I'm using it and it is really great!

UPDATE: And with Vue 3 as the New Default, Volar is recommended in official Vue 3 docs

like image 164
Michal Levý Avatar answered Dec 24 '25 09:12

Michal Levý



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!