组合式函数
useLocalePath
useLocalePath() 组合式函数返回一个函数,该函数根据当前语言环境解析路径。
useLocalePath()
组合式函数返回一个函数,该函数根据当前语言环境解析路径。
类型
declare function useLocalePath(
options?: I18nCommonRoutingOptionsWithComposable
): (route: RawLocation | RouteLocation, locale?: Locale) => string
用法
<script setup>
const localePath = useLocalePath()
</script>
<template>
<NuxtLink :to="localePath('index')">{{ $t('home') }}</NuxtLink>
</template>