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

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.

主站蜘蛛池模板: 林口县| 资阳市| 临海市| 来安县| 马鞍山市| 安康市| 汪清县| 新蔡县| 安阳市| 日照市| 西华县| 翁牛特旗| 修文县| 泌阳县| 商洛市| 汽车| 阿荣旗| 兴国县| 乐陵市| 汾西县| 确山县| 深水埗区| 聂拉木县| 新丰县| 沁水县| 博湖县| 芮城县| 深州市| 许昌县| 阿克| 南雄市| 桃园市| 讷河市| 阳信县| 万山特区| 离岛区| 贡山| 揭阳市| 宣恩县| 南岸区| 米林县|