【vue-i18n踩坑】The message format compilation is not supported in this build.

使用vue3+vite+vue-i18n时,在对不同环境打包时出现development的包翻译失效问题,具体报错如下:

“[intlify] The message format compilation is not supported in this build. Because message compiler isn’t included. You need to pre-compilation all message format. So translate function return ‘book.genderOptionWomen’.”

解决方案:
在vite.config.js配置文件中增加runtimeOnly: false属性,

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueI18n from '@intlify/vite-plugin-vue-i18n'

export default defineConfig({
  plugins: [
    vue(),
    vueI18n({
      runtimeOnly: false
    })
  ]
})

你可能感兴趣的:(vue.js,javascript,ecmascript)