$mol
Cerca
⌘ K
Documentazione
Playground
Confronto
Ecosistema
Informazioni
IT
Da TypeScript a view.tree
Getting Started
Introduzione
Modello mentale
Per iniziare
Da TypeScript a view.tree
Struttura del progetto
Strumenti
Essentials
Installazione
Viste
Stato e reattività
Routing
Rendering
Testing
Deployment
Risoluzione dei problemi
Data
Recupero dati
Schemi di dati
Giper Baza
More
Vetrina
Da React, Vue e Svelte
Ricettario
Advanced
Plugin
Metadati del modulo
Offline
Viste fantasma
About
FAQ
Team
Release
API
$mol_button_major
$mol_button_minor
$mol_string
$mol_number
$mol_text
$mol_paragraph
$mol_list
$mol_row
$mol_link
$mol_check
$mol_switch
$mol_select
$mol_scroll
$mol_page
$mol_pick
Da TypeScript a view.tree
Il componente che hai scritto in
Per iniziare
è una normale classe TypeScript. Compila, funziona, ed è un modo supportato di descrivere un componente $mol — uno dei diversi che il framework accetta.
Ti ha però anche chiesto di tenere a mente quattro cose che non hanno nulla a che vedere con quello che il componente fa. Questa pagina le affronta una alla volta e mostra la riga di
view
.
tree
che elimina ciascuna. Poi mostra il codice generato dal compilatore, così puoi verificare che l'albero non sia un secondo runtime: produce la classe che hai già scritto.
Ecco di nuovo quel file, per il confronto:
1
namespace
$
{
2
3
export class
$my_hello
extends
$mol_page
{
4
5
title
(
)
{
6
return
'Greeting'
7
}
8
9
body
(
)
{
10
return
[
this
.Name
(
)
,
this
.Message
(
)
]
11
}
12
13
@ $mol_mem
14
Name
(
)
{
15
const
obj
=
new
this
.
$
.
$mol_string
16
obj
.
hint
=
(
)
=
>
'Enter your name'
17
obj
.
value
=
(
next
?
:
string
)
=
>
this
.name
(
next
)
18
return
obj
19
}
20
21
@ $mol_mem
22
name
(
next
?
:
string
)
{
23
return
next
?
?
''
24
}
25
26
@ $mol_mem
27
Message
(
)
{
28
const
obj
=
new
this
.
$
.
$mol_view
29
obj
.
sub
=
(
)
=
>
[
this
.greeting
(
)
]
30
return
obj
31
}
32
33
greeting
(
)
{
34
const
name
=
this
.name
(
)
35
return
name
?
`Hello, ${ name }!`
:
'Please enter your name'
36
}
37
38
}
39
40
}
Modifica questa pagina su GitHub
È stato utile?
Sì
No
Precedente
Per iniziare
Successivo
Struttura del progetto
In questa pagina
Il figlio lo costruisci tu, e lo metti in cache tu
La direzione dei dati sta nell'operatore
Il binding bidirezionale è a un tasto dal sola-lettura silenzioso
Una stringa localizzabile resta una stringa finché non ne fai una chiave
Il componente intero
Cosa emette il compilatore
Cosa una classe scritta a mano non può consegnare a uno strumento
Quanto pesa
Quale scrivere
Type to search the documentation.