最新公告
  • 欢迎您光临起源地模板网,本站秉承服务宗旨 履行“站长”责任,销售只是起点 服务永无止境!立即加入钻石VIP
  • element-template slot-scope="scope"的使用

    正文概述 掘金(他说丶)   2020-11-26   957
    1. 实例效果:

    element-template slot-scope="scope"的使用

    1. 实例运用到的组件:

    这里的实例 运用 element 的

    表格组件:el-table

    下拉菜单:el-dropdown;

    1. 用法

    < template slot-scope="scope" >{{ scope.$index }} {{ scope.row }}

    1. 实例代码,详细解释在注释中:

    复制代码

    <el-table-column label="索引值" width="400">
        <template slot-scope="scope">  <!--  slot-scope="scope" 这里取到当前单元格  -->
            <span>{{ scope.$index }}</span>  <!-- scope.$index 直接取到该单元格值  -->
        </template>
    </el-table-column>
    <el-table-column label="标题" width="350">
        <template slot-scope="scope">  <!-- slot-scope="scope" 这里取到当前单元格  -->
            <span>{{ scope.row.title }}</span>
            <!-- scope.row 直接取到该单元格对象,即是tableData[scope.$index]  -->
            <!-- .title 是对象里面的title属性的值  -->
        </template>
    </el-table-column>
    <el-table-column label="操作">
        <template slot-scope="scope">  <!--  slot-scope="scope" 这里取到当前单元格  -->
            <el-dropdown size="medium" split-button type="primary">
                更多
                <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item @click.native.prevent="handleEdit(scope.$index, scope.row)">编辑</el-dropdown-item>
                    <el-dropdown-item @click.native.prevent="getUp(scope.$index, scope.row)">上升</el-dropdown-item>
                    <el-dropdown-item @click.native.prevent="getDown(scope.$index, scope.row)">下降</el-dropdown-item>
                    <el-dropdown-item @click.native.prevent="handleDelete(scope.$index, scope.row)">删除</el-dropdown-item>
                    <!-- 这里的点击事件已经不是在根元素上了,因为多套了几层结构。-->
                    <!-- 这里的点击事件如果没有加上 .native 则点击无效!-->
                    <!--这里的点击事件要加上 .native 表示监听组件根元素的原生事件。-->
                    <!-- 这里的点击事件不需要 .prevent 也可以实现相同效果 -->
                </el-dropdown-menu>
            </el-dropdown>
        </template>
    </el-table-column>
    
    复制代码

    javaScript: 前端删除index要+1

    复制代码 data() { return { tableData: [{title:123,age:11},{title:456,age:18}] //---为了效果先给值,一般情况下为空,其实际值是后台接口请求回来的 } }, methods:{ handleDelete(index, row) { this.tableData.splice(index+1, 1);//---前端删除index要+1 !!!!!!!

      //---下面是后端数据删除
      axios.post(config.newsDelete,//---后端数据删除
          {
            id: row.id//---传入被删除的对象的id值
          },
          {
            headers: {
              Authorization: "Bearer " + sessionStorage.getItem("token")//---请求头验证
            }
          }
        )
        .then(res => {
          this.rendering()//---删除了重新渲染
        });
    }
    

    }


    起源地下载网 » element-template slot-scope="scope"的使用

    常见问题FAQ

    免费下载或者VIP会员专享资源能否直接商用?
    本站所有资源版权均属于原作者所有,这里所提供资源均只能用于参考学习用,请勿直接商用。若由于商用引起版权纠纷,一切责任均由使用者承担。更多说明请参考 VIP介绍。
    提示下载完但解压或打开不了?
    最常见的情况是下载不完整: 可对比下载完压缩包的与网盘上的容量,若小于网盘提示的容量则是这个原因。这是浏览器下载的bug,建议用百度网盘软件或迅雷下载。若排除这种情况,可在对应资源底部留言,或 联络我们.。
    找不到素材资源介绍文章里的示例图片?
    对于PPT,KEY,Mockups,APP,网页模版等类型的素材,文章内用于介绍的图片通常并不包含在对应可供下载素材包内。这些相关商业图片需另外购买,且本站不负责(也没有办法)找到出处。 同样地一些字体文件也是这种情况,但部分素材会在素材包内有一份字体下载链接清单。
    模板不会安装或需要功能定制以及二次开发?
    请QQ联系我们

    发表评论

    还没有评论,快来抢沙发吧!

    如需帝国cms功能定制以及二次开发请联系我们

    联系作者

    请选择支付方式

    ×
    迅虎支付宝
    迅虎微信
    支付宝当面付
    余额支付
    ×
    微信扫码支付 0 元