Skip to content
Tauri 中文网

Nuxt

Nuxt 是 Vue 的元框架。在 https://nuxt.nodejs.cn 了解有关 Nuxt 的更多信息。本指南适用于 Nuxt 3.17 及更高版本。

¥Nuxt is a meta framework for Vue. Learn more about Nuxt at https://nuxt.nodejs.cn. This guide is accurate as of Nuxt 3.17.

¥Checklist

  • 通过设置 ssr: false 使用 SSG。Tauri 不支持基于服务器的解决方案。

    ¥Use SSG by setting ssr: false. Tauri doesn’t support server based solutions.

  • tauri.conf.json 中,将默认 ../dist 用作 frontendDist

    ¥Use default ../dist as frontendDist in tauri.conf.json.

  • 使用 nuxi build 编译。

    ¥Compile using nuxi build.

  • (可选):通过在 nuxt.config.ts 中设置 telemetry: false 来禁用遥测。

    ¥(Optional): Disable telemetry by setting telemetry: false in nuxt.config.ts.

¥Example Configuration

  1. tauri.conf.json
    {
    "build": {
    "beforeDevCommand": "npm run dev",
    "beforeBuildCommand": "npm run build",
    "devUrl": "http://localhost:3000",
    "frontendDist": "../dist"
    }
    }
  2. export default defineNuxtConfig({
    compatibilityDate: '2025-05-15',
    // (optional) Enable the Nuxt devtools
    devtools: { enabled: true },
    // Enable SSG
    ssr: false,
    // Enables the development server to be discoverable by other devices when running on iOS physical devices
    devServer: {
    host: '0',
    },
    vite: {
    // Better support for Tauri CLI output
    clearScreen: false,
    // Enable environment variables
    // Additional environment variables can be found at
    // https://v2.tauri.app/reference/environment-variables/
    envPrefix: ['VITE_', 'TAURI_'],
    server: {
    // Tauri requires a consistent port
    strictPort: true,
    },
    },
    // Avoids error [unhandledRejection] EMFILE: too many open files, watch
    ignore: ['**/src-tauri/**'],
    });

Tauri v2.8 中文网 - 粤ICP备13048890号
Nodejs.cn 旗下网站