Syntax Flashcards
What command initializes a new Nuxt application?
npx create-nuxt-app (project_name)
Which casing style is used for string templates?
PascalCase
Which casing style is used for DOM templates?
kebab-case
What snippet is used to create a basic template, export, style setup for a fresh vue file?
“default” from the “vue” extension in VSC
How do you link between pages in Nuxt.js?
“nuxt-link” element with a “to=’/path/to/file’”
What are the 5 things required to incorporate a component into another file?
- Create the component
- Name the component using “name: ComponentName” in the export object
- Write an import statement in the parent Vue file (i.e. import Component from ‘./partials/component’)
- Add it to the component object in the parent vue file
- Create the custom element in PascalCase within the parent Vue file’s template
* 6. (Depending) Pass properties to the child component who receives them within a “props” object
In Nuxt.js, what are the three things necessary to add a meta tag?
- “hid”, which is used as a unique identifier
- “name”, which is the name of the meta tag
- “content”, which defines the content of that meta tag
What does the “head” section of nuxt.config.js do?
Sets up default head data for each page
In Nuxt.js, how do you overwrite default “head” data for a specific page?
Add a head function to the “export default” statement within the specific file and use the same “hid” property of any corresponding meta tags in the default head data
In Nuxt.js, how would you import Axios to a Vue file?
In the script tag, add the following import statement:
import axios from “axios”;
In Nuxt.js, how do you access a variable within the data() function?
this.objectName
In Nuxt.js, how do you access a URL parameter and display it on the page?
{{ $route.params.param_name }}
In Nuxt.js, how would you create a new page for each item in a list based off of a template Vue file?
- Display the list in the page using a v-for loop and :key
- Create a nuxt-link for each item in the list with the following syntax:
nuxt-link :to=”‘directory’ + keyParamName” - Create a subdirectory in the directory being linked to with this syntax: “_keyParamName”
- Create an index.vue file that will serve as the template
In Nuxt.js, how would you run server-side only code?
add the following to nuxt.config.js after the headsection:
serverMiddleware: [
“~/path/to/api/middleware”
],