Vue学习记录

Vue 使用记录

Vue 的编写函数及自带的函数使用

操作子表格展开和折叠

<template>
    <el-table
        :row-key="getRowKeys"
        :expand-row-keys="expands"
        ref="multipleTable"
        @expand-change="expandSelect"
    >
        <el-table-column
        label="操作"
        min-width="8%"
        align="center">
        <template slot-scope="scope" style="text-align: center">
          <el-button type="text" size="small" @click="moveUp(scope.$index,scope.row)">上移</el-button>
          <el-button type="text" size="small" @click="moveDown(scope.$index,scope.row)">下移</el-button>
          <el-button type="text" size="small" @click="addCondition(scope.$index,scope.row),
                                                      expandSelect2(scope.row,1)">添加条件
          </el-button>
          <el-button size="small" @click="andOrChangeIn(scope.row)">{{ scope.row.andOrFlagIn === "and" ? '且' : '或' }}
          </el-button>
        </template>
      </el-table-column>
    </el-table>
</template>

<script>
    export default {
         data() {
            return {
              getRowKeys(row) {  return row.id },
              expands: [],
            }
         }
         methods: {
        	 // 点击展开标志,展开的关闭,关闭的展开
            expandSelect(row, expandedRows) {
              debugger
              for (let i = 0; i < this.expands.length; i++) {
                if(row.id ===this.expands[i] ){
                  this.expands.splice(i, 1)
                  // this.expands = []
                  return
                }
              }
              // this.expands = []
              row ? this.expands.push(row.id) : ''
            },
            // 点击添加条件展开条件表格
            expandSelect2(row, expandedRows) {
              debugger
              for (let i = 0; i < this.expands.length; i++) {
                if(row.id ===this.expands[i] ){
                  return
                }
              }
              row ? this.expands.push(row.id) : ''
            }
    	}
    }
</script>

Vue 数据操作

删除

<script>
    for (let i in this.list1) { //移除掉list1中的id
      if (this.list1[i] === data.id) {
        this.list1.splice(i, 1)
      }
    }
</script>

数组添加

push(值)

去除对象中的属性

this.$delete(对象,'属性名称')

判断对象中是否有该属性

if (this.attrTable.data[i].hasOwnProperty('children')) {//可以借用,判断子节点参考

数据刷新

this.attrTable.refresh()
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

虎杰青

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值