Item.vue
1.01 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<script>
export default {
name: 'MenuItem',
functional: true,
props: {
icon: {
type: String,
default: ''
},
errorUrl: {
type: String,
default: 'http://img1.xcarimg.com/exp/2872/2875/2937/20101220130509576539.jpg'
},
title: {
type: String,
default: ''
}
},
render(h, context) {
const { icon, title,errorUrl } = context.props
const vnodes = []
if (icon) {
//console.log(icon,'item in icon 这里进行判断处理是相对 还是 绝对地址')
var rxp = /^[a-zA-z]+:\/\/[^\s]*$/;
if(rxp.test(icon)){
vnodes.push(<img class='jpgClass' src={icon} />)
}else{
vnodes.push(<svg-icon icon-class={icon}/>)
}
}
if (title) {
vnodes.push(<span slot='title'>{(title)}</span>)
}
return vnodes
}
}
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
// .el-submenu__title i {
// color: #fff;
// }
.jpgClass{
width: 14px;
height: 14px;
margin-right: 16px;
}
</style>