Unbind on destroy
parent
33f0533a78
commit
0f362e78cb
|
@ -19,19 +19,6 @@
|
||||||
import TerminalService from './TerminalService';
|
import TerminalService from './TerminalService';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
commandText: null,
|
|
||||||
commands: []
|
|
||||||
}
|
|
||||||
},
|
|
||||||
mounted () {
|
|
||||||
TerminalService.$on('response', (response) => {
|
|
||||||
this.commands[this.commands.length - 1].response = response;
|
|
||||||
});
|
|
||||||
|
|
||||||
this.$refs.input.focus();
|
|
||||||
},
|
|
||||||
props: {
|
props: {
|
||||||
welcomeMessage: {
|
welcomeMessage: {
|
||||||
type: String,
|
type: String,
|
||||||
|
@ -42,6 +29,19 @@ export default {
|
||||||
default: null
|
default: null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
commandText: null,
|
||||||
|
commands: []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
TerminalService.$on('response', this.responseListener);
|
||||||
|
this.$refs.input.focus();
|
||||||
|
},
|
||||||
|
beforeDestroy() {
|
||||||
|
TerminalService.$off('response', this.responseListener);
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
onClick() {
|
onClick() {
|
||||||
this.$refs.input.focus();
|
this.$refs.input.focus();
|
||||||
|
@ -52,6 +52,9 @@ export default {
|
||||||
TerminalService.$emit('command', this.commandText);
|
TerminalService.$emit('command', this.commandText);
|
||||||
this.commandText = '';
|
this.commandText = '';
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
responseListener(response) {
|
||||||
|
this.commands[this.commands.length - 1].response = response;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue