Multi-level navigation
This commit is contained in:
32
htdocs/Submenu.vue
Normal file
32
htdocs/Submenu.vue
Normal file
@@ -0,0 +1,32 @@
|
||||
<script>
|
||||
import { menustate } from './common.mjs';
|
||||
|
||||
export default {
|
||||
props: ['value'],
|
||||
data() {
|
||||
return { ptr: null };
|
||||
},
|
||||
watch: {
|
||||
value: {
|
||||
handler(value) {
|
||||
this.update(value);
|
||||
}, immediate: true
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
update(value) {
|
||||
var idx = this.ptr ? menustate.indexOf(this.ptr) : -1;
|
||||
if(idx >= 0) menustate.splice(idx, 1);
|
||||
if(value) {
|
||||
this.ptr = value;
|
||||
if(idx >= 0) menustate.splice(idx, 0, this.ptr);
|
||||
else menustate.unshift(this.ptr);
|
||||
} else this.ptr = null;
|
||||
}
|
||||
},
|
||||
unmounted() {
|
||||
this.update();
|
||||
},
|
||||
render() {}
|
||||
};
|
||||
</script>
|
Reference in New Issue
Block a user