You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Vue.js-Buefy单选框与复选框问题求助(Laravel后端开发)

Troubleshooting Buefy Radio Group Issues in Vue.js

Hey there! I’ve run into similar quirks with Buefy’s radio components before, so let’s break down what might be causing your "Basic Permission" radio button to behave unexpectedly. Here are the top fixes to check:

1. Verify Your v-model Initialization

First up: make sure the permissionType variable you’re binding is properly initialized and reactive. If it’s undefined or doesn’t match one of your radio values, the first selection might not register correctly.

For Vue 2, declare it in your data object with a default value that matches one of your radio value attributes:

export default {
  data() {
    return {
      permissionType: 'basic' // Match the first radio's value here
    }
  }
}

For Vue 3 (using Composition API), use ref to make it reactive:

import { ref } from 'vue'

export default {
  setup() {
    const permissionType = ref('basic')
    return { permissionType }
  }
}

2. Remove Redundant name Attributes

Buefy’s <b-radio-group> automatically handles the name attribute for all child radio buttons. When you manually set name="permission_type" on each <b-radio>, it can create conflicts that break the group’s selection logic. Try removing those:

<div class="block">
  <b-radio-group v-model="permissionType">
    <b-radio value="basic">Basic Permission</b-radio>
    <b-radio value="crud">CRUD Permission</b-radio>
  </b-radio-group>
</div>

3. Confirm Component Registration

If you’re using Buefy via 按需引入 (instead of global installation), double-check that you’ve registered both <b-radio> and <b-radio-group> in your Vue component or main app file. Missing registrations can lead to unexpected rendering or functionality issues.

4. Debug the v-model Value

Add a quick debug line in your template to see if permissionType is updating when you click the radio buttons:

<div class="block">
  <p>Current selection: {{ permissionType }}</p>
  <b-radio-group v-model="permissionType">
    <b-radio value="basic">Basic Permission</b-radio>
    <b-radio value="crud">CRUD Permission</b-radio>
  </b-radio-group>
</div>

If the text doesn’t update when you click "Basic Permission", the issue is with your reactive binding. If it does update but the radio button doesn’t visually reflect the selection, it’s likely a component styling or registration problem.

Give these steps a try—nine times out of ten, one of these fixes will resolve the issue!

内容的提问来源于stack exchange,提问作者B. Milan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 03:55:24