Skip to content

NRadioGroup如何设置默认选中? #5849

Closed Answered by jahnli
evelynn996 asked this question in Q&A
Discussion options

You must be logged in to vote
<template>
  <n-radio-group :value="value" name="radiogroup">
    <n-space>
      <n-radio v-for="song in songs" :key="song.value" :value="song.value">
        {{ song.label }}
      </n-radio>
    </n-space>
  </n-radio-group>
</template>

<script lang="ts">
import { defineComponent, ref } from "vue";

export default defineComponent({
  setup() {
    return {
      value: ref("1"),
      songs: [
        {
          value: "1",
          label: "1",
        },
        {
          value: "2",
          label: "2",
        },
      ].map((s) => {
        s.value = s.value.toLowerCase();
        return s;
      }),
    };
  },
});
</script>

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by jahnli
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants