Vue 3

 0    74 schede    gnomxp
Scarica mp3 Stampa Gioca Testa il tuo livello
 
Domanda Risposta
inicjowanie projektu przez npm
inizia ad imparare
npm init vue@latest
inicjowanie projektu przez vite
inizia ad imparare
npm create vite@latest
tworzenie aplikacji
inizia ad imparare
createApp(component). mount('#app')
globalny error handler
inizia ad imparare
app. errorHandler=(err)=>{}
podłączanie routera
inizia ad imparare
app. use(router)
wstawianie html
inizia ad imparare
v-html="rawHtml"
wiązanie pojedynczego atrybutu, np id
inizia ad imparare
:id="myId"
wiązanie wielu atrybutów, np id i class
inizia ad imparare
v-bind="{id:'myId'class='myClass}"
wstawianie jako tekst, pomiędzy tagi
inizia ad imparare
{{myText}}
wywoływanie funkcji w wyrażeniach, np przy bindowaniu disabled
inizia ad imparare
:disabled="isDisabled()"
wywoływanie funkcji na evencie, np click
inizia ad imparare
@click="doSmt()"
anulowanie domyślnego zachowania eventu, np submit
inizia ad imparare
@submit. prevent="doSmt()"
wywoływanie funkcji z pojedynczym klawiszem specjalnym
inizia ad imparare
@click. ctrl. exact
wywoływanie funkcji na prawym klawiszu myszy
inizia ad imparare
@click. right
bindowanie funkcji na dynamicznym evencie
inizia ad imparare
v-on:[eventName]
przekazywanie defaultowego obiektu event do handlera
inizia ad imparare
@click="doSmt(123,$event)"
nasłuchiwanie w parencie na customowy event
inizia ad imparare
@myEvent="doSmt()"
Hook, the component has finished setting up its reactive state, but no DOM nodes have been created yet
inizia ad imparare
onBeforeMount
Hook, component has finished the initial rendering and created the DOM nodes
inizia ad imparare
onMounted
Hook, can be used to access the DOM state before Vue updates the DOM. It is also safe to modify component state inside this hook.
inizia ad imparare
onBeforeUpdate
Hook, called after the component has updated its DOM tree due to a reactive state change
inizia ad imparare
onUpdated
Hook, all of child components have been unmounted
inizia ad imparare
onUnmounted
Two way data binding in forms
inizia ad imparare
v-model="myValue"
Tags which support v-model
inizia ad imparare
input, textarea, select
Dynamiczna wartość true dla checkboxa
inizia ad imparare
true-value="yes"
v-model radio
inizia ad imparare
input type="radio" value="myValue" v-model="myRef"
v-model zastępuje
inizia ad imparare
input: value="text" @input="event => text=event. target. value"
2 way binding w parent'cie, np referencji parentRefName
inizia ad imparare
v-model: propChildName="parentRefName"
2 way binding w child'zie, np referencji propChildName
inizia ad imparare
defileProps(['propChildName']); defineEmits(['update: propChildName'])<input: value="propChildName" @input="$emit('update: propChildName', $event. target. value)"
updatowanie zbindowanej wartości po evencie change
inizia ad imparare
v-model. lazy="text"
castowanie zbindowanego modelu na number, np wieku
inizia ad imparare
v-model. number="age"
trimowanie zbindowanego modelu, np ulicy
inizia ad imparare
v-model. trim="street"
iterowanie po obiektach
inizia ad imparare
v-for="(item, index) in items": key="item. id"
iterowanie po zakresie liczb
inizia ad imparare
v-for="n in 10": key="n"
iterowanie po kluczach obiektu
inizia ad imparare
v-for="(value, key, index) in myObject"
referencja z typem
inizia ad imparare
ref<number>()
dyrektywa css display
inizia ad imparare
v-show
korzystanie z nazwanego slotu w parencie, np childSlotName
inizia ad imparare
template #childSlotName
korzystanie z nienazwanego slotu w parencie
inizia ad imparare
template #default
definiowanie slotu w child'zie
inizia ad imparare
slot name="childSlotName"
dyrektywa anulująca aktualizację componentu na zmianach referencji
inizia ad imparare
v-once
referencja DOM, np myInput
inizia ad imparare
input ref="myInput">const myInput=ref(null)
focusowanie pola w formularzu on load
inizia ad imparare
onMounted(()=>{myInput. value. focus()})
bindowanie klas css jako inline condition
inizia ad imparare
:class="{'myClass1': isClass1, 'myClass2': isClass2 }"
bindowanie klas css jako computed
inizia ad imparare
const myClasses=computed(()=>({'myClass1': isClass1, 'myClass2': isClass2 }): class="myClasses"
bindowanie klas css jako array refów
inizia ad imparare
const myClasses=ref(['myClass1', 'myClass2']): class="myClasses"
cashowanie stanu komponentu kiedy nie jest już wyświetlany
inizia ad imparare
const myComp=shallowRef(MyComp) <KeepAlive><component: is="myComp">
tranzycja
inizia ad imparare
. v-enter-active,. v-leave-active {transition: opacity 0.5s ease}. v-enter-from,. v-leave-to {opacity: 0}
customowa dyrektywa focus
inizia ad imparare
const vFocus={mounted: (el) => el. focus()} <input v-focus />
transition between components
inizia ad imparare
transition mode="out-in"
watcher na referencji
inizia ad imparare
watch(myRef, async (newValue, oldValue) => {})
watcher który jest trigerowany na każdej zmianie referencji
inizia ad imparare
watchEffect(async () => {await fetch('https://mydomian.com/${myRef. value}`)})
eager watcher
inizia ad imparare
{immediate: true}
obserwowanie wyniku wyrażenia
inizia ad imparare
watch(() => (first. value+second. value), (sum)=>{})
asynchroniczne wgrywanie componentów
inizia ad imparare
defineAsyncComponent({loader, loadingComponent, delay, errorComponent, timeout})
routing guard
inizia ad imparare
router. beforeEach(async (to, from, next) => {})
router init
inizia ad imparare
createRouter({history: createWebHistory(), routes: [{path" ", component: MyComp}]})
deklarowanie wstrzykiwanej wartości
inizia ad imparare
provide('myRef', myRef)
wstrzykiwanie wartości
inizia ad imparare
const myRef=inject('myRef')
What is the CLI command to create a new Vue. js SPA with the official Vue project scaffolding tool (create-vue)?
inizia ad imparare
npm init vue@latest
Hook called after the component instance is inserted into the DOM as part of a tree cached by <KeepAlive>
inizia ad imparare
onActivated
Hook called after the component instance is removed from the DOM as part of a tree cached by <KeepAlive>
inizia ad imparare
onDeactivated
Hook to be called when an error propagating from a descendant component has been captured
inizia ad imparare
onErrorCaptured
Component used to create links between routes
inizia ad imparare
RouterLink
Component to embed router content placeholder
inizia ad imparare
RouterView
Get value of a route param, like id
inizia ad imparare
const route = useRoute() const id = parseInt(route. params. id)
Redirect with view router
inizia ad imparare
redirect: to => ({path: '/'})
Programatic router redirect with query param
inizia ad imparare
router. push({path: '/register', query: {plan: 'private'}})
Redirect in router with history replacement
inizia ad imparare
router. replace
wstrzykiwanie parametrów do props w routerze
inizia ad imparare
props: route => ({myparam: route. params. myparam})
dyrektywa która odpali eventhandler tylko taż
inizia ad imparare
once
disable fallthrough attribute propagation
inizia ad imparare
defineOptions({inheritAttrs: false})
access fallthrough attribute
inizia ad imparare
$attrs
bindowanie wszystkich fallthrough attributes
inizia ad imparare
v-bind="attrs"

Devi essere accedere per pubblicare un commento.