可以用到自己的项目中,首页跳转
跟着步骤来
用脚手架创建项目
![](https://file.jishuzhan.net/article/1739938574947586050/c2708517a2ff230a815cc8cf018427da.webp)
用VScode打开项目
![](https://file.jishuzhan.net/article/1739938574947586050/1e92fe2fb6ced8a78ba355e0713e9e47.webp)
打开终端
安装element-ui
javascript
npm i element-ui -S
![](https://file.jishuzhan.net/article/1739938574947586050/a6c1e2fd0ba9cb9d6ba4bbce405288a5.webp)
安装less lessloder
javascript
npm install --save less less-loader@5
![](https://file.jishuzhan.net/article/1739938574947586050/7458e68402aadd87c49291e80064f50d.webp)
打开VScode
在main.js中引入
javascript
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
Vue.use(ElementUI)
![](https://file.jishuzhan.net/article/1739938574947586050/5205bbb2531feb04615a052b4415bbab.webp)
直接在HelloWorld使用代码
中间用了一些icon图标
![](https://file.jishuzhan.net/article/1739938574947586050/35f8129812327025f9989f0cf68dad8d.webp)
App.vue中删除初始的图片和样式
![](https://file.jishuzhan.net/article/1739938574947586050/d4e9e6be7dd65a4a9f6b22d2843edd57.webp)
运行结果
完整代码:
App.vue
javascript
<template>
<div id="app">
<HelloWorld></HelloWorld>
</div>
</template>
<script>
import HelloWorld from './components/HelloWorld.vue'
export default {
name: 'App',
components: {
HelloWorld
}
}
</script>
<style>
#app{
margin: 50px;
}
</style>
HelloWorld.vue
javascript
<template>
<el-popover placement="top" width="160" v-model="visible">
<span class="iconfont icon-fangjian"></span>
<el-button size="mini" type="text" @click="visible = false" class="indexPage">首页</el-button>
<el-button slot="reference" ><span class="iconfont icon-dian"></span></el-button>
</el-popover>
</template>
<script>
export default {
data() {
return {
visible: false
}
}
}
</script>
<style lang="less" scoped>
@font-face {
font-family: 'iconfont'; /* Project id 4389994 */
src: url('//at.alicdn.com/t/c/font_4389994_1e4wqmnv1phh.woff2?t=1703644505103') format('woff2'),
url('//at.alicdn.com/t/c/font_4389994_1e4wqmnv1phh.woff?t=1703644505103') format('woff'),
url('//at.alicdn.com/t/c/font_4389994_1e4wqmnv1phh.ttf?t=1703644505103') format('truetype');
}
.iconfont {
font-family: "iconfont" !important;
font-size: 22px;
font-style: normal;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.icon-dian:before {
content: "\e623";
}
.icon-fangjian:before {
content: "\e62e";
color: blue;
}
.title{
margin: -25px -10px 0 0;
}
.indexPage{
border: none;
color: #000;
font-size:20px;
padding: 0 0 0 10px;
background-color: transparent;
}
</style>