VUE引入Element

组件网址http://element-cn.eleme.io/#/zh-CN

首先,VUE项目需要安装组件,

方式一npm:

进入项目根目录后执行

cnpm  i  element-ui -S

方式二:CDN

<!-- 引入样式 --><link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">

<!-- 引入组件库 --><script src="https://unpkg.com/element-ui/lib/index.js"></script>

我在上一篇博客的基础上使用方式一,之后修改src下的main.js文件:

// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
//引入Element
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'

Vue.config.productionTip = false

/* eslint-disable no-new */
//引用Element
Vue.use(ElementUI)

new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>'
})

注意:是 import 'element-ui/lib/theme-chalk/index.css'而不是 import 'element-ui/lib/theme-default/index.css'。

现在就可以在项目中直接引用Element了,如在HelloWord中加上:

<el-button type="primary" icon="el-icon-search">搜索</el-button>

npm run dev运行项目后可以看到:

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

w_t_y_y

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值