N
Nuxt2y ago
Romi

Console.log the selected value (id)

Hi, I'm having trouble trying to console.log the id of the selected driver
2 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Romi
Romi2y ago
that worked on load but not when updating I did manage to use
watch(selected, (newVal) => {
console.log(newVal.id);
});
watch(selected, (newVal) => {
console.log(newVal.id);
});
to get it to work But then I could not work out how to pass that value to the parent After some time manage to get the interaction between the two components Child Comp:
<script>
import { ref } from "vue";

export default {
setup(props, context) {
const selected = ref("option1");

const handleSelect = () => {
// console.log(`Selected option: ${selected.value}`);
context.emit("selectedDriver", selected.value);
};

return {
selected,
handleSelect,
};
},
};
</script>
<script>
import { ref } from "vue";

export default {
setup(props, context) {
const selected = ref("option1");

const handleSelect = () => {
// console.log(`Selected option: ${selected.value}`);
context.emit("selectedDriver", selected.value);
};

return {
selected,
handleSelect,
};
},
};
</script>
Parent Comp:
myAction() {
console.log("myAction");
},
myAction() {
console.log("myAction");
},
But was not sure how to pass the selected value in the log... @Sr. Full Stack Dev if you get some time 🙂
Want results from more Discord servers?
Add your server