gpt4 book ai didi

Toggle a checkbox into quasar q-table(将复选框切换到类星体Q表)

转载 作者:bug小助手 更新时间:2023-10-25 12:09:13 26 4
gpt4 key购买 nike



I am trying to edit a checkbox into quasar q-table.

我正在尝试编辑一个复选框到类星体Q表中。


I have created a codepen: https://codepen.io/luizalves/pen/PoXpBrV?editors=101

我创建了一个代码员:https://codepen.io/luizalves/pen/PoXpBrV?editors=101


My problem is when I click the checkbox, it´s not changing.

我的问题是,当我点击复选框时,S没有改变。


I´d like the checkbox changing when I click and a event to save it in a DB.

我希望在单击时更改复选框,并希望事件将其保存到数据库中。


// markup

//标记


<div id="q-app" style="min-height: 100vh;">
<div class="q-pa-md">
<q-table
flat bordered
title="Treats"
:rows="rows"
:columns="columns"
row-key="name"
binary-state-sort
>
<template v-slot:body="props">
<q-tr :props="props">
<q-td key="name" :props="props">
{{ props.row.name }}
<q-popup-edit v-model="props.row.name" v-slot="scope">
<q-input v-model="scope.value" dense autofocus counter @keyup.enter="scope.set"></q-input>
</q-popup-edit>
</q-td>
<q-td key="isBlackListed" :props="props">
{{ props.row.isBlackListed }}
<q-popup-edit
v-model="props.row.isBlackListed"
buttons
v-slot="scope"
>
<q-checkbox
v-model="scope.isBlackListed"
dense
label="BlackListed"
autofocus
@click="scope.isBlackListed = !scope.isBlackListed"
/>
</q-popup-edit>
</q-td>
<q-td key="calories" :props="props">
{{ props.row.calories }}
<q-popup-edit v-model="props.row.calories" title="Update calories" buttons v-slot="scope">
<q-input type="number" v-model="scope.value" dense autofocus></q-input>
</q-popup-edit>
</q-td>
<q-td key="fat" :props="props">
<div class="text-pre-wrap">{{ props.row.fat }}</div>
<q-popup-edit v-model="props.row.fat" v-slot="scope">
<q-input type="textarea" v-model="scope.value" dense autofocus></q-input>
</q-popup-edit>
</q-td>
<q-td key="carbs" :props="props">
{{ props.row.carbs }}
<q-popup-edit v-model="props.row.carbs" title="Update carbs" buttons persistent v-slot="scope">
<q-input type="number" v-model="scope.value" dense autofocus hint="Use buttons to close"></q-input>
</q-popup-edit>
</q-td>
<q-td key="protein" :props="props">{{ props.row.protein }}</q-td>
<q-td key="sodium" :props="props">{{ props.row.sodium }}</q-td>
<q-td key="calcium" :props="props">{{ props.row.calcium }}</q-td>
<q-td key="iron" :props="props">{{ props.row.iron }}</q-td>
</q-tr>
</template>
</q-table>
</div>
</div>

// script

//脚本


const { ref } = Vue

const columns = [
{
name: 'name',
required: true,
label: 'Dessert (100g serving)',
align: 'left',
field: row => row.name,
format: val => `${val}`,
sortable: true
},
{ name: 'isBlackListed', align: 'center', label: 'BlackListed', field: 'isBlackListed', sortable: false },
{ name: 'calories', align: 'center', label: 'Calories', field: 'calories', sortable: true },
{ name: 'fat', label: 'Fat (g)', field: 'fat', sortable: true, style: 'width: 10px' },
{ name: 'carbs', label: 'Carbs (g)', field: 'carbs' },
{ name: 'protein', label: 'Protein (g)', field: 'protein' },
{ name: 'sodium', label: 'Sodium (mg)', field: 'sodium' },
{ name: 'calcium', label: 'Calcium (%)', field: 'calcium', sortable: true, sort: (a, b) => parseInt(a, 10) - parseInt(b, 10) },
{ name: 'iron', label: 'Iron (%)', field: 'iron', sortable: true, sort: (a, b) => parseInt(a, 10) - parseInt(b, 10) }
]

const rows = [
{
name: 'Frozen Yogurt',
isBlackListed:false,
calories: 159,
fat: 6.0,
carbs: 24,
protein: 4.0,
sodium: 87,
calcium: '14%',
iron: '1%'
},
{
name: 'Ice cream sandwich',
isBlackListed:false,
calories: 237,
fat: 9.0,
carbs: 37,
protein: 4.3,
sodium: 129,
calcium: '8%',
iron: '1%'
},
{
name: 'Eclair',
isBlackListed:false,
calories: 262,
fat: 16.0,
carbs: 23,
protein: 6.0,
sodium: 337,
calcium: '6%',
iron: '7%'
},
{
name: 'Cupcake',
isBlackListed:false,
calories: 305,
fat: 3.7,
carbs: 67,
protein: 4.3,
sodium: 413,
calcium: '3%',
iron: '8%'
},
{
name: 'Gingerbread',
isBlackListed:false,
calories: 356,
fat: 16.0,
carbs: 49,
protein: 3.9,
sodium: 327,
calcium: '7%',
iron: '16%'
},
{
name: 'Jelly bean',
isBlackListed:false,
calories: 375,
fat: 0.0,
carbs: 94,
protein: 0.0,
sodium: 50,
calcium: '0%',
iron: '0%'
},
{
name: 'Lollipop',
isBlackListed:false,
calories: 392,
fat: 0.2,
carbs: 98,
protein: 0,
sodium: 38,
calcium: '0%',
iron: '2%'
},
{
name: 'Honeycomb',
isBlackListed:false,
calories: 408,
fat: 3.2,
carbs: 87,
protein: 6.5,
sodium: 562,
calcium: '0%',
iron: '45%'
},
{
name: 'Donut',
isBlackListed:false,
calories: 452,
fat: 25.0,
carbs: 51,
protein: 4.9,
sodium: 326,
calcium: '2%',
iron: '22%'
},
{
name: 'KitKat',
isBlackListed:false,
calories: 518,
fat: 26.0,
carbs: 65,
protein: 7,
sodium: 54,
calcium: '12%',
iron: '6%'
}
]

const app = Vue.createApp({
setup () {
return {
columns,
rows: ref(rows)
}
}
})

app.use(Quasar, { config: {} })
app.mount('#q-app')

更多回答
优秀答案推荐

You need to use scope.value and it will work.

您需要使用Scope.Value,它就会起作用。


Codepen - https://codepen.io/Pratik__007/pen/qBLrePK

Codesen-https://codepen.io/Pratik__007/pen/qBLrePK


<q-popup-edit
v-model="props.row.isBlackListed"
buttons
v-slot="scope"
>
<q-checkbox
v-model="scope.value"
dense
label="BlackListed"
autofocus
/>
</q-popup-edit>

更多回答

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com