VUE ROUTER: EASY STEPS TO ADDING ROUTING TO YOUR VUE APPLICATION

tyanae

Tatyana Effa

Posted on June 15, 2023

VUE ROUTER: EASY STEPS TO ADDING ROUTING TO YOUR VUE APPLICATION

Adding routing to your Vue application can be a bit of a hassle, particularly if you are new to Vue.js. I will be sharing a straightforward method to implement routing in this blog post using Vue CLI

Setting Up:

The easiest way to get started with setting up routing in your Vue application is by creating a new project using Vue CLI and have CLI set up routing for you.

To get started, open your terminal or command prompt and follow these steps:

  • Navigate to the directory where you want to create your new project. In this example, we will create the project in the Documents folder. You can change the directory path according to your preference.
cd Documents
Enter fullscreen mode Exit fullscreen mode

changing dircetory

  • Once you have done this, use the following command to create a new Vue project named "my-router" (you can replace "my-router" with your preferred project name):
vue create my-router
Enter fullscreen mode Exit fullscreen mode
  • Vue CLI will prompt you to select a preset for your project. Scroll down to "manually select features" and press Enter.

select features

By choosing the "Manually select features" option, you'll have more control over your Vue project. This allows you to handpick the specific features and plugins you want to include in your project, including routing.

  • After selecting the "Manually select features" option, a prompt will appear with a list of features to choose from. Scroll down using the arrow keys until you reach the "Router" option. Press the space bar to select it, indicated by a filled checkbox.

Next, scroll down to the "Linter" option and press the space bar to unselect it, indicated by an empty checkbox.

select

Once you have made these selections, press Enter to proceed.

  • The next prompt will ask you to choose a version. Select the latest version by scrolling down and highlighting it, then press Enter.

select version

  • Following that, Vue CLI will ask if you want to use history mode for the router. Reply with "Y" to choose yes.

history mode

  • Next, you will be prompted to select the configuration file format. Select the default config file by pressing Enter.

config

  • next select no "N' to saving it as a preset.

preset

Press enter and you will generate your vue application

vue app

When you open your newly generated Vue application in VS Code, you will find that the router has been set up for you. You can now personalize it to meet your specific needs and requirements.

vscode

If you found this blog post helpful, I would love to hear from you! Drop a comment below! Share your thoughts, feedback, or any additional tips and tricks you have discovered along the way.

Happy coding!

💖 💪 🙅 🚩
tyanae
Tatyana Effa

Posted on June 15, 2023

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related