![]() ![]() You import it after vue, and you call Vue.use(VueRouter) to install it inside the app: import Vue from 'vue' import VueRouter from 'vue-router' Vue. Once you install vue-router and make it available either using a script tag or via Vue CLI, you can now import it in your app. If you use the Vue CLI, install it using npm install vue-router is a very handy tool that makes every npm package available in the browser with a simple link If you use Vue via a script tag, you can include Vue Router using Vue Router is available via npm with the package named vue-router. This means it’s maintained by the same people who maintain Vue, so you get a more consistent integration in the framework, and the guarantee that it’s always going to be compatible in the future, no matter what. You can use whatever generic routing library you want, or also create your own History API integration, but the benefit of using Vue Router is that it’s official. Vue does not enforce the use of this library. The Vue Router library is the way to go for Vue.js applications. It’s a very common need, and all the major modern frameworks now allow you to manage routing. You need a router when you need to sync URLs to views in your app. With the introduction of applications that run inside the browser and change what the user sees, many applications broke this interaction, and you had to manually update the URL with the browser’s History API. When you hit a certain URL, a specific page is displayed. Traditionally the Web is built around URLs. In other words, it’s the part that makes the URL change when you click something in the page, and helps to show the correct view when you hit a specific URL. In a JavaScript web application, a router is the part that syncs the currently displayed view with the browser address bar content. How to use the Vue Router, one of the essential pieces of a Vue application ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |