Vue шитпостинг, желтуха, советы и мысли
Дополнительный канал к @zede_code от @zede1697
Post #100
2.66K

Не хочу ничего более обсуждать. Сегодня на улице праздник!
- 😁 57
- 👍 20
- 🔥 7
- ❤🔥 5
- 🎉 2
- 🤡 2
- 🤯 1
- 🤝 1
VU @vueist

<template lang="pug">: позволит эффективнее использовать переменные в шаблонах, делать преиспользуемые части без костылей и сильно лаконичнееimport { ref } from 'vue'
defineProps<{
title: string
}>()
const count = ref(0)
export default () => (
<section>
<h3>{title}</h3>
<button onClick={() => count.value++}>+1</button>
<p v-if={count.value === 0}>Пока пусто</p>
<p v-else>Счёт: {count.value}</p>
<ul>
<li v-for={(item, index) in count.value} key={index}>
Элемент #{item}
</li>
</ul>
</section>
)@reference "../../app.css"
radius = 16px
gap = 12px
.card
@apply rounded-xl border border-slate-200 bg-white p-4 shadow-sm
border-radius radius
&--active
@apply ring-2 ring-blue-500
&__title
@apply text-lg font-semibold text-slate-900
margin-bottom gap
&__text
@apply text-sm text-slate-600
&__button
@apply mt-3 inline-flex items-center rounded-md bg-slate-900 px-3 py-2 text-sm font-medium text-white transition
&:hover
@apply bg-slate-700
@media (min-width: 768px)
@apply p-6
// stores/counter.ts
import { atom } from 'nanostores'
import { Subject } from 'rxjs'
export const $count = atom(0)
const increment$ = new Subject<void>()
increment$.subscribe(() => {
$count.set($count.get() + 1)
})
export function increment() {
increment$.next()
}
<template v-match="theme">
<link v-case="'dark'" rel="stylesheet" href="/dark.css" />
<link v-case="'light'" rel="stylesheet" href="/light.css" />
<link v-case.default rel="stylesheet" href="/default.css" />
</template>
<!-- Parent.vue -->
<script setup lang="ts">
import { ref } from 'vue'
const count = ref(0)
</script>
<template>
<button @click="count++">increment</button>
<CountDisplay :count />
</template>
<component name="CountDisplay">
<script setup lang="ts">
const { count } = defineProps<{ count: number }>()
</script>
<template>
<p>Current count: {{ count }}</p>
</template>
</component>

This post (sticker, poll or similar) has no web preview. Open in Telegram
почему нежелательно использовать классы вместо компосаблов.
Forwarded from HolyJS — канал конференции

useRoute`/`$routedefinePage либо через новый блок в SFC <route>vue vapor во vue router (иначе ждать его релиза не придется)This post (sticker, poll or similar) has no web preview. Open in Telegram








@vuejs/components-meta и был им недаволен, теперь намеревается его переписать<!-- @strictTemplates -->. И данная директива включает строгую проверку шаблонов (по факту аналог strict в TS, но включается строгая проверка существования компонентов с их пропсами ивентами и тд)