Zum Hauptinhalt springen
ProdukteDesktop-WerkzeugeTASTECADZeichnungsprüfungTASTEFILESDateiverwaltungTASTEFTPDateiübertragungTASTESSHRemote-ArbeitsbereichTASTEZIPKomprimieren und EntpackenTASTEWINMDateiverwaltungEntwicklerwerkzeugeTASTECODEIntegrierte Entwicklungsumgebung für RustTASTESTUDIOIntegrierte Entwicklungs- und TestumgebungTASTEETLDatenintegration (ETL)ServerTASTEREMOTERemote-Desktop-ServerTASTEGEOGeodatenserverTASTEMAILE-Mail-ArbeitsbereichInvestierenTASTESTOCKDesktop-App für automatischen AktienhandelErste SchritteDownloadsDokumentationKaufenAlle Produkte
Marktplatz
Neuigkeiten
TechnikNeuigkeitenEntwickler-News von heuteEntwicklerdokuProgrammiersprachenRustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDartWeb-Frontend-FrameworksNext.jsReactVue.js · NuxtSvelteKitAngularServer-FrameworksSpring BootDjangoFastAPIASP.NET CoreNestJS · ExpressApp- & Desktop-FrameworksTauriFlutterReact NativeElectronAlgorithmenAlgorithmus-GrundlagenKernalgorithmenFortgeschrittene AlgorithmenAlgorithmen für die Praxis
CommunityProjekteEntwicklungslogsPromptsProbleme mit KI-ToolsShowcaseCommunity-Leitfaden
ZusammenarbeitWissenstransferWebsite-AufbauDesktop-App-AufbauRelease- und ZahlungspipelineVertriebspartnerKontakt
DiensteRemote-DesktopIndividuelle Installationspakete
TASTEDEV
Produkte

Desktop-Werkzeuge

TASTECADKomplexe Zeichnungen, mühelos geöffnetTASTEFILESNur die Dateien, die zählen – in BestzeitTASTEFTPDer aufgeräumteste Weg für Ihre DateienTASTESSHDie stärkere Verbindung zu Ihren ServernTASTEZIPSchneller packen, sicherer entpackenTASTEWINMEin tastaturorientierter Dateimanager mit zwei Fenstern

Entwicklerwerkzeuge

TASTECODERust-Apps bearbeiten, bauen, debuggen und testen – alles in einem FensterTASTESTUDIOVom Bearbeiten bis zu Remote-Tests und freigegebenen KI-KorrekturenTASTEETLDaten bewegen, die Werte im Blick

Server

TASTEREMOTEEin Remote-Desktop auf Ihrem eigenen ServerTASTEGEOEin GeoServer-kompatibler Geodatenserver, neu aufgebaut in RustTASTEMAILIhre E-Mail wieder in Ihrer Hand

Investieren

TASTESTOCKAutomatischer Aktienhandel nach Ihren Regeln: wann und was

Erste Schritte

DownloadsNeueste Versionen aller ProdukteDokuSo nutzen Sie jedes ProduktKaufenAbos und DauerlizenzenAlle ProdukteAlle Produkte im Überblick
Alle Produkte
MarktplatzNeuigkeiten
Technik

Neuigkeiten

Entwickler-News von heuteOffizielle Meldungen zu Sprachen, Frameworks, GitHub und KIEntwicklerdokuAnleitungen zu Sprachen, Frameworks und Algorithmen

Programmiersprachen

RustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDart

Frameworks

Web-Frontend-FrameworksNext.jsReactVue.js · NuxtSvelteKitAngular
Server-FrameworksSpring BootDjangoFastAPIASP.NET CoreNestJS · Express
App- & Desktop-FrameworksTauriFlutterReact NativeElectron

Algorithmen

Algorithmus-GrundlagenKomplexitätsanalyse · Sortieren · Suchen · Grundlegende Datenstrukturen · Bäume und HeapsKernalgorithmenGraphtraversierung · Kürzeste Wege und minimale Spannbäume · Dynamische Programmierung · Greedy-Algorithmen · Teile und herrsche · BacktrackingFortgeschrittene AlgorithmenZeichenkettenalgorithmen · Mathematik und Zahlentheorie · Bitmanipulation · Segmentbäume · Union-FindAlgorithmen für die PraxisStrategie für Coding-Interviews · LRU-Cache · Rate Limiting · Konsistentes Hashing
Alle Entwicklungsdokumente
Community
ProjekteEntwickler und Projekte entdeckenEntwicklungslogsEntscheidungen und ErkenntnissePromptsWiederverwendbare AnweisungenProbleme mit KI-ToolsProbleme und Workarounds für Claude, Codex, GeminiShowcaseFertige ErgebnisseCommunity-LeitfadenWie wir offen entwickeln
Zusammenarbeit
WissenstransferNative Apps mit Rust und eguiWebsite-Aufbau10 Sprachen, Konten, Dokumentation und DownloadsDesktop-App-AufbauRust und egui, ohne WebViewRelease- und ZahlungspipelineSignatur, MSI, deb, rpm, AppImage, PrüfsummenVertriebspartnerEmpfehlen und 30 % erhaltenKontaktEntwicklung, Partnerschaft, Investition
Dienste
Remote-DesktopIhren Computer im Browser erreichenIndividuelle InstallationspaketeNur nötige Funktionen, Einstellungen vorab
Kaufen
DE
한국어EnglishDeutschEspañolFrançaisItalianoPortuguês (Brasil)日本語简体中文繁體中文
Anmelden
Anmelden
TASTEDEV

Von kleinen Werkzeugen zu besserer Entwicklung.

support@tastedev.netTASTEDEV unterstützen
ProdukteProduktübersichtKaufenDokuDownloadsMarktplatzSupport
CommunityProjekteEntwicklungslogsPromptsProbleme mit KI-ToolsShowcase
RichtlinienÜber unsDatenschutzerklärungNutzungsbedingungenAbo-BedingungenRückerstattungCommunity-Richtlinien
KontoAnmeldenRegistrieren
Besucher
Heute
Gestern
Aufrufe gesamt
Firma
GXSOFT
Vertretungsberechtigt
CHOI YOUNG GU
Handelsregisternummer
853-44-00368
Anschrift
9F V24, 351 Gyeongin-ro, Michuhol-gu, Incheon, Republic of Korea
Telefon
+82-10-4404-1523
E-Mail
whitecalvin@tastedev.net
Datenschutzbeauftragter
CHOI YOUNG GU

© 2026 TASTEDEVProduktinformationen basieren auf verifizierten Entwicklungsquellen.Veröffentlicht · wird verbessert

Vue.js · Nuxt-Dokumentation
Vue.js · Nuxt
Getting Started with Vue and NuxtProject StructureCore Concepts: SFCs, Reactivity, Components, Nuxt RoutingData and StateTestingBuild and Deployment
Diskussionen

Vue.js · Nuxt-Anleitung · 4/6

Data and State

Dieses Kapitel ist vorerst nur auf Englisch verfügbar.

As an app grows, two questions matter more and more: where state should live, and how server data gets loaded. This chapter covers reusing logic with composables, managing global state with Pinia, and exchanging data through Nuxt's useFetch, useAsyncData and server routes.

Choosing where state lives

Scope of the stateWhere to keep it
Inside one componentThe component's ref or reactive
Between parent and childProps and emits, or provide and inject
Shared across screensA Pinia store
Data from the serveruseFetch or useAsyncData (Nuxt), or a composable

Rather than putting everything in a global store from day one, keep state as close as possible to where it is used and lift it up only when sharing becomes necessary.

Reusing logic with composables

A composable is a function, named with a use prefix, that bundles reactive state and logic and returns them. Reach for one when several components need the same behavior.

// composables/useCounter.ts
import { ref, computed } from "vue";

export function useCounter(initial = 0) {
  const count = ref(initial);
  const double = computed(() => count.value * 2);
  const increment = () => count.value++;
  const reset = () => (count.value = initial);
  return { count, double, increment, reset };
}

In a component, write const { count, increment } = useCounter(10);. Every call creates independent state. In Nuxt, functions in the composables/ folder are auto-imported.

Global state with Pinia

Pinia is the official state management library for Vue. Stores are defined with defineStore, and the setup syntax looks just like a composable: ref becomes state, computed becomes a getter, and functions become actions.

// stores/cart.ts
import { defineStore } from "pinia";
import { ref, computed } from "vue";

type Item = { id: number; name: string; price: number; qty: number };

export const useCartStore = defineStore("cart", () => {
  const items = ref<Item[]>([]);
  const total = computed(() => items.value.reduce((sum, i) => sum + i.price * i.qty, 0));

  function add(item: Omit<Item, "qty">) {
    const found = items.value.find((i) => i.id === item.id);
    if (found) found.qty++;
    else items.value.push({ ...item, qty: 1 });
  }

  return { items, total, add };
});

Destructuring state straight off a store breaks reactivity, so use . Actions can be destructured as they are.

Fragen zu diesem Kapitel?
Vorheriges KapitelCore Concepts: SFCs, Reactivity, Components, Nuxt RoutingNächstes KapitelTesting
storeToRefs
<script setup lang="ts">
import { storeToRefs } from "pinia";
import { useCartStore } from "@/stores/cart";

const cart = useCartStore();
const { items, total } = storeToRefs(cart);
</script>

<template>
  <p>{{ items.length }} items, total {{ total }}</p>
  <button @click="cart.add({ id: 1, name: 'Book', price: 15 })">Add to cart</button>
</template>

In Nuxt, add the @pinia/nuxt module with npx nuxi module add pinia; state created during server rendering is then transferred safely to the client.

Nuxt server routes

Files in server/api/ become API endpoints. Adding .get or .post before the extension restricts the HTTP method.

// server/api/todos.get.ts
export default defineEventHandler(async (event) => {
  const { done } = getQuery(event);
  const todos = [
    { id: 1, text: "Learn Vue", done: true },
    { id: 2, text: "Deploy Nuxt", done: false },
  ];
  return done === undefined ? todos : todos.filter((t) => String(t.done) === done);
});

// server/api/todos.post.ts
export default defineEventHandler(async (event) => {
  const body = await readBody<{ text: string }>(event);
  if (!body?.text) {
    throw createError({ statusCode: 400, statusMessage: "text is required" });
  }
  return { id: Date.now(), text: body.text, done: false };
});

Returned objects are serialized as JSON. In a real service, this is where you call a database or an external API, reading secrets with useRuntimeConfig(event).

useFetch and useAsyncData

Use useFetch to load data for a page. During server rendering the result is fetched once and shipped with the page, so the client does not repeat the request.

<script setup lang="ts">
const { data: todos, status, error, refresh } = await useFetch("/api/todos");

async function addTodo(text: string) {
  await $fetch("/api/todos", { method: "POST", body: { text } });
  await refresh();
}
</script>

<template>
  <p v-if="status === 'pending'">Loading...</p>
  <p v-else-if="error">Error: {{ error.message }}</p>
  <ul v-else>
    <li v-for="todo in todos" :key="todo.id">{{ todo.text }}</li>
  </ul>
</template>

useFetch is shorthand for useAsyncData(key, () => $fetch(url)). Call useAsyncData directly when you combine several requests or call something other than $fetch, such as a database SDK. For requests triggered by user actions, like a button click, use $fetch. For simple state shared between server and client, useState("key", () => initialValue) creates an SSR-safe ref.

Summary

  • Keep state close to where it is used; move it into a composable or Pinia store when it needs to be shared.
  • Use storeToRefs when pulling state out of a Pinia store.
  • Files in Nuxt's server/api/ create endpoints with defineEventHandler.
  • Load page data with useFetch or useAsyncData, and send user-triggered requests with $fetch.

0 Kommentare

Top-KommentareNeueste zuerst

Anmelden · Melde dich an, um einen Kommentar zu schreiben.