Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 1717306

Browse files
committed
Add composition API questions
1 parent 5924b1e commit 1717306

File tree

1 file changed

+30
-4
lines changed

1 file changed

+30
-4
lines changed

‎README.md‎

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,8 @@ List of 300 VueJS Interview Questions
235235
|226| [What happens if you use duplicate field names?](#what-happens-if-you-use-duplicate-field-names)|
236236
|227| [Why the component data must be a function?](#why-the-component-data-must-be-a-function)|
237237
|228| [What is the reason for recommendation for multi-word component names?](#what-is-the-reason-for-recommendation-for-multi-word-component-names)|
238-
|229| [](#)|
239-
|230| [](#)|
238+
|229| [How to use composition API in Vue2.0?](#how-to-use-composition-api-in-vue2.0)|
239+
|230| [What is composition API?](#what-is-composition-api)|
240240

241241
1. ### What is VueJS?
242242
**Vue.js** is an open-source, progressive Javascript framework for building user interfaces that aim to be incrementally adoptable. The core library of VueJS is focused on the `view layer` only, and is easy to pick up and integrate with other libraries or existing projects.
@@ -4941,10 +4941,36 @@ List of 300 VueJS Interview Questions
49414941
49424942
**[⬆ Back to Top](#table-of-contents)**
49434943
4944-
229. ### ?
4944+
229. ### How to use composition API in Vue2.0?
4945+
Even though the Composition API is a part of Vue 3, it has been made available for Vue 2 as well by installing `@vue/composition-api` as a plugin via `Vue.use()`.
4946+
4947+
Let's see the usage in step by step instructions,
4948+
4949+
1. Run the below commands to install
4950+
```javascript
4951+
npm install @vue/composition-api
4952+
# or
4953+
yarn add @vue/composition-api
4954+
```
4955+
4956+
2. After that import this API in your main.js file,
4957+
4958+
```js
4959+
import Vue from 'vue'
4960+
import VueCompositionAPI from '@vue/composition-api'
4961+
4962+
Vue.use(VueCompositionAPI)
4963+
```
4964+
3. Now your project is able to use composition API
4965+
4966+
```js
4967+
// use the APIs
4968+
import { ref, reactive } from '@vue/composition-api'
4969+
```
49454970
49464971
**[⬆ Back to Top](#table-of-contents)**
49474972
4948-
230. ### ?
4973+
230. ### What is composition API?
4974+
Composition API is a set of additive, function-based APIs that allow flexible composition of component logic.
49494975
49504976
**[⬆ Back to Top](#table-of-contents)**

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /