Each element in the vue array has a column of calculated attributes. Attribute sum= attribute a + attribute b

has been implemented, solution

Apr.03,2021

such requirements are not recommended to use computed, you can use filter, custom functions, or even curly braces to do operations

< hr >

if sum is also editable at the same time, manually change sum to 0 and the values of an and b are also changed to 0 . Who is the person who mentioned this requirement and can have a fight with him

?

it's okay to change sum to 0, to 1, so who is 1, an or b? How about changing it to 9? There are so many combinations, how do you define them? If you just change it to zero, you might as well add a button or a click event to make the data go back to zero

.

it's much easier to use elementUI's table

<template>
    <div>
        <el-table :data="data" border >
          <el-table-column label="a" prop="a"></el-table-column>
          <el-table-column label="b" prop="b"></el-table-column>
          <el-table-column label="sum">
              <template slot-scope="scope">
                  {{scope.row.a + scope.row.b}}
              </template>
          </el-table-column>
        </el-table>
    </div>
</template>

<script>
export default {
    data(){
        return {
            data: [
                {
                    a: 1,
                    b: 2,
                },
                {
                    a: 1,
                    b: 2,
                },
            ]
        }
    }
}
</script>
< hr >
if sum is also editable at the same time, manually change sum to zero and the values of an and b also become 0

there are still people who mention this kind of need.


has been resolved, using watch's deep monitoring

just take one of the cash channels as an example:

my current way of writing is

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b32ece-2ab99.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b32ece-2ab99.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?