sunny123456

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
  1796 随笔 :: 22 文章 :: 24 评论 :: 226万 阅读
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

在vue中进行ElementUI 组件的安装、引入

1. 安装、引入elementUI

  1. cmd进入vue项目所在文件夹
  2. 安装 elementUI

npm i element-ui -S

  1. 在main.js中引入
import ElementUI from 'element-ui'; //element-ui的全部组件
import 'element-ui/lib/theme-chalk/index.css'; //element-ui的css


Vue.use(ElementUI); //使用elementUI


  • 1
  • 2
  • 3
  • 4

2. 测试是否引入成功

  1. 在components 文件夹下新建一个test.vue文件,将测试代码粘贴过去
    测试代码如下:
<template>
    <el-menu :default-active="activeIndex2" class="el-menu-demo" mode="horizontal" @select="handleSelect" background-color="#545c64" text-color="#fff" active-text-color="#ffd04b">
        <el-menu-item index="1">处理中心</el-menu-item>
        <el-submenu index="2">
            <template slot="title">我的工作台</template>
            <el-menu-item index="2-1">选项1</el-menu-item>
            <el-menu-item index="2-2">选项2</el-menu-item>
            <el-menu-item index="2-3">选项3</el-menu-item>
        </el-submenu>
        <el-menu-item index="3">
            <a href="https://www.ele.me" target="_blank">订单管理</a>
        </el-menu-item>
    </el-menu>
</template>


<script>

export default {

data() {

return {

activeIndex: '1',

activeIndex2: '1'

};

},

methods: {

handleSelect(key, keyPath) {

console.log(key, keyPath);

}

}

}

</script>


  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  1. 在App.vue中引入test.vue
<template>
  <div id="app">
    <Test></Test>
    <router-view/>
  </div>
</template>


<script>

import Test from "./components/test.vue"




export default {

//组件

components:{

Test,//速写属性

},

name: 'App'

}

</script>




<style>



app {



font-family: 'Avenir', Helvetica, Arial, sans-serif;

-webkit-font-smoothing: antialiased;

-moz-osx-font-smoothing: grayscale;

text-align: center;

color: #2c3e50;

margin-top: 60px;

}

</style>


  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  1. 启动项目,查看结果

npm run dev

效果:
在这里插入图片描述
引入成功啦!

https://blog.csdn.net/weixin_44109827/article/details/125542774
posted on   sunny123456  阅读(807)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· .NET10 - 预览版1新功能体验(一)
历史上的今天:
2021-09-01 Microsoft Visio 2013 简体中文版
2021-09-01 visio2013产品密钥激活
2021-09-01 WebConfigurationManager和ConfigurationManager区别
2021-09-01 错误 the type "xxxx" is defined in an assembly that is not refernced.You must add a reference to assem
2021-09-01 Windows10安装oracle 19c数据库+PLsql详细安装过程
点击右上角即可分享
微信分享提示