Files
EdgeAdmin/web/public/js/components/common/menu-item.js

45 lines
1.1 KiB
JavaScript
Raw Normal View History

2020-07-22 22:19:39 +08:00
/**
* 菜单项
*/
Vue.component("menu-item", {
props: ["href", "active", "code"],
data: function () {
let active = this.active
2020-11-24 17:36:42 +08:00
if (typeof (active) == "undefined") {
var itemCode = ""
2020-07-22 22:19:39 +08:00
if (typeof (window.TEA.ACTION.data.firstMenuItem) != "undefined") {
2020-11-24 17:36:42 +08:00
itemCode = window.TEA.ACTION.data.firstMenuItem
2020-07-22 22:19:39 +08:00
}
2021-07-03 15:44:49 +08:00
if (itemCode != null && itemCode.length > 0 && this.code != null && this.code.length > 0) {
if (itemCode.indexOf(",") > 0) {
active = itemCode.split(",").$contains(this.code)
} else {
active = (itemCode == this.code)
}
}
2020-07-22 22:19:39 +08:00
}
let href = (this.href == null) ? "" : this.href
if (typeof (href) == "string" && href.length > 0 && href.startsWith(".")) {
let qIndex = href.indexOf("?")
if (qIndex >= 0) {
href = Tea.url(href.substring(0, qIndex)) + href.substring(qIndex)
} else {
href = Tea.url(href)
}
}
2020-07-22 22:19:39 +08:00
return {
vHref: href,
2020-07-22 22:19:39 +08:00
vActive: active
2020-11-24 17:36:42 +08:00
}
},
methods: {
click: function (e) {
this.$emit("click", e)
}
2020-07-22 22:19:39 +08:00
},
template: '\
2020-11-24 17:36:42 +08:00
<a :href="vHref" class="item" :class="{active:vActive}" @click="click"><slot></slot></a> \
2020-07-22 22:19:39 +08:00
'
});