Converting a Vue component to the Composition API

Опубликовано: 19 Май 2022
на канале: Andrew Schmelyun
6,324
219

In this 14 minute video, I'll walk you through as I convert an existing Vue component from the Options API to the newer Composition API. I created a basic e-commerce shopping cart with the Options API, containing props, methods, and computed properties. In this high-level overview, I transform that component to use the Composition API, which has a drastically different code structure (but one that I think you'll enjoy).

You'll learn:

What script setup does
The difference between ref and reactive
How to create methods and computed properties
Why to switch to the Composition API

0:00 Intro
02:10 Getting started with setup()
03:33 Introducing ref and reactive
05:11 Using script setup
06:32 Including props
07:02 Adding methods
09:22 Including computed properties
11:38 Why use the Composition API
14:09 Wrapping up

Follow me on Twitter!   / aschmelyun  

Join my newsletter, where I send out new information twice each month in the PHP, JavaScript, and Docker worlds: https://aschmelyun.substack.com


Смотрите видео Converting a Vue component to the Composition API онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь Andrew Schmelyun 19 Май 2022, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 6,324 раз и оно понравилось 219 людям.