Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

117
Views
Model prop, event in vue

I've Radio component, which uses model in export default.

<template>
  <div class="radio">
    <label class="radio__container">
      <input
        type="radio"
        :name="name"
        :value="value"
        :checked="isChecked"
        :disabled="disabled"
        @change="changeHandler"
        @input="inputHandler"
      />
      <slot name="checkmark" v-bind="{ isChecked, disabled }">
        <span class="radio__checkmark" />
      </slot>
      <span class="radio__content">
        <slot name="label" v-bind="{ label, isChecked, disabled }">
          <span class="radio__label" v-text="label" />
        </slot>
      </span>
    </label>
  </div>
</template>

<script>
export default {
  name: "Radio",
  model: {
    prop: "selected",
    event: "change",
  },
  props: {
    name: {
      type: String,
      default: "",
    },
    value: {
      type: String,
      default: "",
    },
    label: {
      type: String,
      default: "",
    },
    disabled: {
      type: Boolean,
      default: false,
    },
    selected: {
      type: String,
      default: "",
    },
  },
  computed: {
    isChecked() {
      return this.value === this.selected;
    },
  },
  methods: {
    changeHandler() {
      this.$emit("change", this.value);
    },
    inputHandler() {
      this.$emit("input", this.value);
    },
  },
};
</script>

I need to refactor it to vue 3 <script setup> and I don't know what to do with

model: {
  prop: "selected",
  event: "change",
}

Has anyone any suggestion?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can try this https://vuejs.org/guide/components/events.html#usage-with-v-model

Example:

<input
  @input="(event) => $emit('update:checked', event.target.checked)"
  type="checkbox"
  :checked="checked"
/>

props: ['checked'],
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!