Vue.js Flashcards

1
Q

What are the 5 steps to initializing a Vue web application?

A
  1. Install vue-cli globally with: npm install -g vue-cli
  2. Initialize the project from a template with: vue init
  3. Change directory: cd
  4. Install dependencies: npm install
  5. Run in development mode: npm run dev
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What command is used to start the application in development mode?

A

npm run dev

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What commands are used to run the application for production?

A

npm run build

npm run start

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Name all of the Vue lifecycle hooks

A

created
mounted
updated
destroyed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are lifecycle hooks in Vue?

A

Lifecycle hooks are the defined methods which get executed in a certain stage of the Vue object lifespan

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

In Nuxt.js, how would you pull data from an API call to use when a component is created?

A

Use an async created() lifecycle hook with axios to make the API call

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

In Vue.js, what does @submit.prevent do?

A

It prevents the default behavior of a submit button when it is clicked (the way that preventDefault() does in JavaScript to an event)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the syntax for an “emit” statement in Vue.js?

A

this.$emit(‘var-name’, this.varName);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

In Vue.js, what do you need to do in a parent template in order to receive an emitted variable?

A

add an event listener with the following syntax:
“ComponentName @emitted-var-name=”receivingMethod” /”
Then, create the receiving method:
receivingMethod(varName) {
this.parentVar = varName;
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

In Vue.js, which directive is used in order to make a two–way data binding connection between an element and a variable in the data()?

A

v-model

How well did you know this?
1
Not at all
2
3
4
5
Perfectly