Skip to content
프로젝트

소개

[OUTDATED IN 2022!] Vue 3 Composition API examples!

웹 및 앱 개발

이 수치를 측정하는 방법

측정된 스타 증가

in 24h
0
in 7 days
0
in 15 days
0
in 1 month
기록 수집 중

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original

Vue 3 Composition API examples

Project setup


yarn install

Docker setup

Build the container

docker-compose build

Run the container (Add -d flag to launch without the logs)

docker-compose up

Stop the container

docker-compose down

Project explanation

Vue 3's function-based API was proposed in an RFC in May 2019, and it was divisive. I wanted to better understand the benefits and so I created this repository for the purposes of better appreciating some of the changes that will be coming down the line.

The project was used in conjunction with a presentation that I made for VueJS Glasgow's meetup.

The project

The project is divided into a series of little apps that demonstrate how to achieve some of the basic Vue 2.x outcomes with Vue 3.0's API.

The Todo list was forked from a handy Codepen made by @sharon-the-encoder (@CodeFa on Github) - which sped up my intial work!

What I've learned:

Grouping your data together makes sense:

We all love Vue's very clean, consistent data, methods, computed structure. But it doesn't always make sense. Forcing types of actions or data together means that your method which mutates a data property might be at the top and bottom of the file. Vue 3 means we can group relevant actions and data them together.

Vue 2.x vs 3 component structure

Hooks are smarter mixins

Mixins are helpful, no doubt - but they're dumb helpers. Hooks allow us to use smarter imports with explicit logic origin. If you have a file with several mixins, the origin of the data/methods/computed etc that are you now have access to is not immediately obvious. Hooks have us import what we need to use from them, and so we can clearly track our data's origin.

Hooks can also communicate with each other, something that mixins couldn't do.

Vue 2.x: Vue 2.x mixins

Vue 3.0:

Vue 3.0 hooks

관련 프로젝트 살펴보기

불러오는 중…