官术网_书友最值得收藏!

Adding plugins to a Vue CLI project with Vue UI

The Vue UI tool is one of the most powerful additional tools for Vue development. It makes a developer's life easier, and at the same time can help manage the Vue projects.

Getting ready

The pre-requisite for this recipe is as follows:

  • Node.js 12+

The Node.js global objects that are required are as follows:

  • @vue/cli
  • @vue/cli-service-global

How to do it...

First, we need to create our Vue CLI project. To find how to create a Vue CLI project, please check the 'Creating your first project with Vue CLI' recipe. We can use the one we created in the last recipe or start a new one. Now, follow the instructions to add a plugin:

  1. Open the Vue UI interface. Open Terminal (macOS or Linux) or Command Prompt/PowerShell (Windows) and execute the following command:
> vue ui
  1. A new browser window will appear, with the Vue UI interface:

Here, you can list your projects, create a new project, or import an existing one.

  1. Now, we will import the one we created:

You need to find the folder that you created and click on Import this folder.

  1. After the folder is imported, the default Dashboard of the project will appear:

Here, it's possible to customize your Dashboard, adding new widgets, by clicking on the Customize button on the top:

  1. To add a new plugin, you must click on the Plugins menu in the left-hand sidebar:

The base plugins that you added on the Vue CLI tool will be already listed here. 

  1. Now, we will add the base Vue ecosystem plugins—vuex and vue-router:

  1. If you check your code, you will see that the main.js file was changed, and the vuex (store) and vue-router (router) plugins are now imported and injected to the Vue instance:

How it works...

The Vue UI plugins work in conjunction with npm or yarn to automatically install the packages on your project, and then inject—when possible—the necessary conditions on the Vue instance.

If a plugin is a visual, directive, or a non-direct instantiated plugin, the Vue UI will install it and manage it, but you need to import it for use on your application.

主站蜘蛛池模板: 林州市| 苍梧县| 若羌县| 浑源县| 江川县| 成武县| 侯马市| 绥化市| 新田县| 阿坝县| 清苑县| 阿合奇县| 凤阳县| 通江县| 西青区| 抚远县| 泽州县| 梁山县| 沅陵县| 中山市| 五华县| 恩施市| 宣化县| 霍城县| 英超| 马公市| 罗甸县| 潍坊市| 桐庐县| 桃园市| 濮阳县| 紫云| 思南县| 卢氏县| 正定县| 邵东县| 昆山市| 政和县| 岑巩县| 敖汉旗| 五指山市|