Nuxt.js is really easy to get started with. A simple project only needs thenuxtdependency.
Using create-nuxt-app
To get started quickly, the Nuxt.js team has created scaffolding tool create-nuxt-app.Make sure you have npx installed (
npx is shipped by default since NPM 5.2.0)$ npx create-nuxt-app <project-name>
Or with yarn:yarn create nuxt-app <my-project>
It will ask you some questions:- Choose between integrated server-side frameworks:
- Choose your favorite UI framework:
- The Nuxt mode you want (
UniversalorSPA) - Add axios module to make HTTP request easily into your application.
- Add EsLint to Lint your code on save.
- Add Prettier to prettify your code on save.
$ npm run dev
The application is now running on http://localhost:3000.
Nuxt.js will listen for file changes inside the
To discover more about the directory structure of the project: Directory Structure Documentation.pages directory, so there is no need to restart the application when adding new pages.Starting from scratch
Creating a Nuxt.js application from scratch is also really easy, it only needs 1 file and 1 directory. Let's create an empty directory to start working on the application:$ mkdir <project-name>
$ cd <project-name>
Info: replace
<project-name> by the name of the project.The package.json
The project needs apackage.json file to specify how to start nuxt:{
"name": "my-app",
"scripts": {
"dev": "nuxt"
}
}
scripts will launch Nuxt.js via npm run dev.
Installing nuxt
Once the package.json has been created, add nuxt to the project via npm:npm install --save nuxt
The pages directory
Nuxt.js will transform every *.vue file inside the pages directory as a route for the application.Create the
pages directory:$ mkdir pages
then create the first page in pages/index.vue:<template>
<h1>Hello world!</h1>
</template>
and launch the project with:$ npm run dev
The application is now running on http://localhost:3000.
Nuxt.js will listen for file changes inside the
pages directory, so there is no need to restart the application when adding new pages.
No comments:
Post a Comment