antd vue3 (a-switch开关)
antd vue的a-switch
   ·  
 <template v-if="column.key === 'status'">
            <a-switch
              :disabled="!user.authorities.includes('schedule:update')"
              :loading="loading"
              :checked="record.status"
              :checked-value="1"
              :unchecked-value="2"
              @change="editStatus(record)"
            />
          </template>
| checkedValue | 选中时的值 | 
| unCheckedValue | 非选中时的值 | 
| checked(v-model) | 指定当前是否选中 | 
/** 修改用户状态 */
  const editStatus = async (row: InspectionScheduleDTO) => {
    loading = true
    const status = row.status === 1 ? 2 : 1
    try {
      await putInspectionScheduleEffective({
        id: row.id,
        status
      })
      row.status = status
      message.success('修改成功')
      reload()
    } catch (err: any) {
      message.error(err.message)
    } finally {
      loading = false
    }
  }
const status = row.status === 1 ? 2 : 1 如果选中的值为1的话就把它变成2,否则就变成1
更多推荐
 


所有评论(0)