34 lines
665 B
Vue
34 lines
665 B
Vue
|
<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;
|
||
|
console.log(menustate)
|
||
|
}
|
||
|
},
|
||
|
unmounted() {
|
||
|
this.update();
|
||
|
},
|
||
|
render() {}
|
||
|
};
|
||
|
</script>
|