vue2: Build ElementUI's basic project environment based on VueCli

What kind of website is ElementUI suitable for writing?
Background management website

1. Create a new VueCli project. element-project. (project for Vue 2.x)

Install scaffolding

npm install -g @vue/cli 

Set npm Taobao source to speed up the download speed

npm config set registry https://registry.npm.taobao.org

find a clean directory

vue create element-project 等一会
Manually select features
选择:Babel - Router - Css Preprocessors 去掉linter
2.x
以下选项一路回车即可

2. Execute the command to install the ElementUI component library.

Enter the project directory and execute the installation command

cd element-project
npm i element-ui -S

Download the source code of the element-ui component library from the warehouse and put it in node_modules. And the -S option will add this dependency
to the package.json configuration file

3. Introduce all elements and styles of ElementUI in main.js.

import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
// use()方法可以将ElementUI中的所有组件全部引入当前Vue项目
// 一旦在此处引入,每一个组件都将可以使用ElementUI的组件
Vue.use(ElementUI);

4. Use ElementUI components.

<template>
<div>
<el-button>默认按钮</el-button>
</div>
</template>

Guess you like

Origin blog.csdn.net/qq_51463650/article/details/129998912