laravel +vue+element-UI如何去取数据和取一行数据

在搭建好laravel+vue+element-UI的项目后,我们在element-UI的组件中我们发现,取后台数据的方式跟以前的VUE不一样的。
以前VUE我们用v-for来取数据进行循环,在element-UI中用data取数据循环:data=""如下:

<el-table :data="site_nodes" style="width: 100%" class="site_top" @selection-change="handleSelectionChange">
            <el-table-column type="selection"></el-table-column>
            <el-table-column label="编号" prop="id" width="80"></el-table-column>
            <el-table-column label="名称" prop="name"></el-table-column>
            <el-table-column label="排序" prop="sort">
                <template slot-scope="scope">
                    <el-input v-model="scope.row.sort" placeholder="请输入内容" style="width:15%" @change="sort(scope.$index, scope.row)"></el-input>
                </template>
            </el-table-column>
            <el-table-column label="操作">
                <template slot-scope="scope">
                    <el-button size="mini" @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
                    <el-button size="mini" type="danger" @click="handleDelete(scope.$index, scope.row)">删除</el-button>
                </template>
            </el-table-column>
        </el-table>

如何去取一行数据,在你要取数据(循环体标签内)的地方加上scope就可以进行取数据

<template slot-scope="scope"> </template>

操作带上函数名(scope.$index, scope.row)",调用时函数名(index, row){//console.log(index, row);}

猜你喜欢

转载自blog.csdn.net/weixin_43674113/article/details/84029576