I've made a VueJS component that operates some <select>
elements. The result of this UI is that the user selects a value.
I have a function in the compoent's computed
for showing the user's selected value on screen.
How do I pass this value back to the parent VueJS thingy?
It seems to be something to so with $emit
but I don't see that I have an event.
I've tied to raise one as suggested here, but nowt happens.
In the component:
computed: {
selectedCode: function () {
var selected = '(No code selected.)';
if (this.category) { selected = this.category; }
if (this.code) { selected = this.code; }
this.$emit('selectedCode', selected);
return selected;
},
In the parent Vue app:
<code-selector v-bind:code="code" v-on:selectedCode="codeSelect"></sic-selector>
and
methods:
{
selectedCode: function (z) {
console.log(z);
},