Vai al contenuto principale
ProdottiStrumenti desktopTASTECADVisualizzazione disegniTASTEFILESGestione fileTASTEFTPTrasferimento fileTASTESSHSpazio di lavoro remotoTASTEZIPCompressione ed estrazioneTASTEWINMGestione fileStrumenti per sviluppatoriTASTECODEAmbiente di sviluppo integrato per RustTASTESTUDIOAmbiente integrato di sviluppo e testTASTEETLIntegrazione dati (ETL)ServerTASTEREMOTEServer di desktop remotoTASTEGEOServer geospazialeTASTEMAILSpazio di lavoro emailInvestimentiTASTESTOCKApp desktop di trading automatico azionarioIniziaDownloadDocumentazioneAcquistaTutti i prodotti
Marketplace
Notizie
TecnologiaNotizieNotizie di sviluppo di oggiDocumentazioneLinguaggi di programmazioneRustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDartFramework frontend webNext.jsReactVue.js · NuxtSvelteKitAngularFramework serverSpring BootDjangoFastAPIASP.NET CoreNestJS · ExpressFramework per app e desktopTauriFlutterReact NativeElectronAlgoritmiBasi degli algoritmiAlgoritmi fondamentaliAlgoritmi avanzatiAlgoritmi pratici
CommunityProgettiLog di sviluppoPromptProblemi degli strumenti di IAVetrinaGuida alla community
CollaboraTrasferimento tecnicoRealizzazione del sito webRealizzazione di app desktopPipeline di rilascio e pagamentoPartner commercialeContatti
ServiziDesktop remotoPacchetti di installazione su misura
TASTEDEV
Prodotti

Strumenti desktop

TASTECADApri con leggerezza anche i disegni più complessiTASTEFILESSolo i file che servono, alla massima velocitàTASTEFTPLa via più ordinata per i tuoi fileTASTESSHUn legame più solido tra te e i tuoi serverTASTEZIPComprimi più veloce, estrai più sicuroTASTEWINMUn file manager a due pannelli pensato per la tastiera

Strumenti per sviluppatori

TASTECODEModifica, compila, esegui il debug e testa app Rust in un'unica finestraTASTESTUDIODalla modifica ai test remoti e alle correzioni IA approvateTASTEETLSposta i dati guardando i valori

Server

TASTEREMOTEUn desktop remoto che gira sul tuo serverTASTEGEOUn server geospaziale compatibile con GeoServer, ricostruito in RustTASTEMAILRiprendi il controllo della tua posta

Investimenti

TASTESTOCKTrading automatico azionario secondo le regole che decidi tu: quando e che cosa

Inizia

DownloadUltime versioni di ogni prodottoDocsCome usare ogni prodottoAcquistaAbbonamenti e licenze perpetueTutti i prodottiTutti i prodotti a colpo d’occhio
Tutti i prodotti
MarketplaceNotizie
Tecnologia

Notizie

Notizie di sviluppo di oggiAnnunci ufficiali su linguaggi, framework, GitHub e IADocumentazioneGuide a linguaggi, framework e algoritmi

Linguaggi di programmazione

RustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDart

Framework

Framework frontend webNext.jsReactVue.js · NuxtSvelteKitAngular
Framework serverSpring BootDjangoFastAPIASP.NET CoreNestJS · Express
Framework per app e desktopTauriFlutterReact NativeElectron

Algoritmi

Basi degli algoritmiAnalisi della complessità · Ordinamento · Ricerca · Strutture dati di base · Alberi e heapAlgoritmi fondamentaliVisita dei grafi · Cammini minimi e alberi ricoprenti · Programmazione dinamica · Algoritmi greedy · Divide et impera · BacktrackingAlgoritmi avanzatiAlgoritmi sulle stringhe · Matematica e teoria dei numeri · Manipolazione dei bit · Alberi di segmenti · Union-FindAlgoritmi praticiStrategia per colloqui di programmazione · Cache LRU · Rate limiting · Hashing consistente
Tutta la documentazione di sviluppo
Community
ProgettiScopri sviluppatori e lavoriLog di sviluppoDecisioni e lezioni appresePromptIstruzioni riutilizzabiliProblemi degli strumenti di IAProblemi e alternative di Claude, Codex, GeminiVetrinaRisultati completatiGuida alla communityCome sviluppiamo in modo aperto
Collabora
Trasferimento tecnicoApp native in Rust ed eguiRealizzazione del sito web10 lingue, account, documentazione e downloadRealizzazione di app desktopRust ed egui, senza WebViewPipeline di rilascio e pagamentoFirma, MSI, deb, rpm, AppImage, hashPartner commercialeConsigliaci e ricevi il 30%ContattiSviluppo, partnership e investimenti
Servizi
Desktop remotoRaggiungi il tuo computer dal browserPacchetti di installazione su misuraSolo il necessario, impostazioni precaricate
Acquista
IT
한국어EnglishDeutschEspañolFrançaisItalianoPortuguês (Brasil)日本語简体中文繁體中文
Accedi
Accedi
TASTEDEV

Dai piccoli strumenti a uno sviluppo migliore.

support@tastedev.netSostieni TASTEDEV
ProdottiGamma di prodottiAcquistaDocsDownloadMarketplaceAssistenza
CommunityProgettiLog di sviluppoPromptProblemi degli strumenti di IAVetrina
NormeChi siamoInformativa sulla privacyTermini di servizioCondizioni di abbonamentoRimborsiLinee guida della community
AccountAccediRegistrati
Visitatori
Oggi
Ieri
Visualizzazioni totali
Società
GXSOFT
Rappresentante
CHOI YOUNG GU
Numero di registrazione
853-44-00368
Indirizzo
9F V24, 351 Gyeongin-ro, Michuhol-gu, Incheon, Republic of Korea
Telefono
+82-10-4404-1523
E-mail
whitecalvin@tastedev.net
Responsabile privacy
CHOI YOUNG GU

© 2026 TASTEDEVLe informazioni sui prodotti si basano su fonti di sviluppo verificate.Rilasciato · in miglioramento

Documentazione di Vue.js · Nuxt
Vue.js · Nuxt
Getting Started with Vue and NuxtProject StructureCore Concepts: SFCs, Reactivity, Components, Nuxt RoutingData and StateTestingBuild and Deployment
Discussioni

Guida a Vue.js · Nuxt · 4/6

Data and State

Per ora questo capitolo è disponibile solo in inglese.

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.

Domande su questo capitolo?
Capitolo precedenteCore Concepts: SFCs, Reactivity, Components, Nuxt RoutingCapitolo successivoTesting
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 commenti

Commenti principaliPrima i più recenti

Accedi · Accedi per lasciare un commento.