• Spa项目开发(动态树&数据表格&分页)


    一、动态树

    LeftNav.vue

    router :default-active="$route.path"  default-active="2" class="el-menu-vertical-demo" background-color="#334157" text-color="#fff"
        active-text-color="#ffd04b" :collapse="collapsed">
       
       


         
       

       
         
         
         
           
            {{m2.treeNodeName}}
         

       

     

    二、数据表格

    在项目的src中创建views/sys目录,在此目录下创建Articles.vue文件

    文件里添加如下代码

    Articles.vue

    1. <template>
    2. <div>
    3. <!--列表-->
    4. <el-table size="small" :data="listData" highlight-current-row v-loading="loading" border
    5. element-loading-text="拼命加载中" style="width: 100%;">
    6. <el-table-column align="center" type="selection" width="60">
    7. </el-table-column>
    8. <el-table-column sortable prop="id" label="编号" width="100">
    9. </el-table-column>
    10. <el-table-column sortable prop="title" label="文章标题" width="100">
    11. </el-table-column>
    12. <el-table-column sortable prop="body" label="文章内容" width="300">
    13. </el-table-column>
    14. <el-table-column align="center" label="操作" min-width="100">
    15. <template slot-scope="scope">
    16. <el-button size="mini" @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
    17. <el-button size="mini" type="danger" @click="deleteUser(scope.$index, scope.row)">删除</el-button>
    18. </template>
    19. </el-table-column>
    20. </el-table>
    21. </div>
    22. </template>
    23. <script>
    24. export default {
    25. name: 'Articles',
    26. data() {
    27. return {
    28. listData: {}
    29. }
    30. },
    31. created() {
    32. let url = this.axios.urls.SYSTEM_ARTICLE_LIST;
    33. this.axios.post(url, param).then(res => {
    34. console.log(res);
    35. this.listData = res.data.result;
    36. this.formInline.total = res.data.pageBean.total;
    37. }).catch(function(error) {
    38. console.log(error);
    39. });
    40. }
    41. }
    42. </script>

    router/index.js

    import Articles from '@/views/sys/Articles'
    1. {
    2. path: '/AppMain',
    3. name: 'AppMain',
    4. component: AppMain,
    5. children: [{
    6. path: '/LeftNav',
    7. name: 'LeftNav',
    8. component: LeftNav
    9. },
    10. {
    11. path: '/TopNav',
    12. name: 'TopNav',
    13. component: TopNav
    14. },
    15. {
    16. path: '/sys/Articles',
    17. name: 'Articles',
    18. component: Articles
    19. }
    20. ]
    21. }

     运行后

     

    三、分页

    Articles.vue

    1. <template>
    2. <div>
    3. <!-- 搜索筛选 -->
    4. <el-form :inline="true" :model="formInline" class="user-search">
    5. <el-form-item label="搜索:">
    6. <el-input size="small" v-model="formInline.title" placeholder="输入文章标题"></el-input>
    7. </el-form-item>
    8. <el-form-item>
    9. <el-button size="small" type="primary" icon="el-icon-search" @click="search">搜索</el-button>
    10. <el-button size="small" type="primary" icon="el-icon-plus" @click="handleEdit()">添加</el-button>
    11. </el-form-item>
    12. </el-form>
    13. <!--列表-->
    14. <el-table size="small" :data="listData" highlight-current-row v-loading="loading" border
    15. element-loading-text="拼命加载中" style="width: 100%;">
    16. <!-- <el-table-column align="center" type="selection" width="60">
    17. </el-table-column> -->
    18. <el-table-column align="center" sortable prop="id" label="编号" width="100">
    19. </el-table-column>
    20. <el-table-column sortable prop="title" label="文章标题" width="100">
    21. </el-table-column>
    22. <el-table-column sortable prop="body" label="文章内容" width="300">
    23. </el-table-column>
    24. <el-table-column align="center" label="操作" min-width="100">
    25. <template slot-scope="scope">
    26. <el-button size="mini" @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
    27. <el-button size="mini" type="danger" @click="deleteUser(scope.$index, scope.row)">删除</el-button>
    28. </template>
    29. </el-table-column>
    30. </el-table>
    31. <!-- 分页条 -->
    32. <el-pagination style="margin-top: 20px;" @size-change="handleSizeChange" @current-change="handleCurrentChange"
    33. :current-page="formInline.page" :page-sizes="[10, 20, 30, 50]" :page-size="100"
    34. layout="total, sizes, prev, pager, next, jumper" :total="formInline.total">
    35. </el-pagination>
    36. </div>
    37. </template>
    38. <script>
    39. export default {
    40. name: 'Articles',
    41. data() {
    42. return {
    43. listData: {},
    44. formInline: {
    45. page: 1,
    46. rows: 10,
    47. total: 0,
    48. title: ''
    49. }
    50. }
    51. },
    52. created() {
    53. this.dosearch({});
    54. },
    55. methods: {
    56. handleSizeChange(rows) {
    57. console.log("当前页查询数量为:" + rows);
    58. this.formInline.page = 1;
    59. this.formInline.rows = rows;
    60. this.search();
    61. },
    62. handleCurrentChange(page) {
    63. console.log("当前页为:" + page);
    64. this.formInline.page = page;
    65. this.search();
    66. },
    67. dosearch(param) {
    68. let url = this.axios.urls.SYSTEM_ARTICLE_LIST;
    69. this.axios.post(url, param).then(res => {
    70. console.log(res);
    71. this.listData = res.data.result;
    72. this.formInline.total = res.data.pageBean.total;
    73. }).catch(function(error) {
    74. console.log(error);
    75. });
    76. },
    77. search() {
    78. this.dosearch(this.formInline);
    79. }
    80. }
    81. }
    82. </script>
    83. <style>
    84. </style>

     

  • 相关阅读:
    Kotlin 委托
    Yolov8小目标检测(26):多尺度空洞注意力(MSDA) | 中科院一区顶刊 DilateFormer 2023.9
    JDK7多线程并发环境HashMap死循环infinite loop,CPU拉满100%,Java
    dubbo Can not lock the registry cache file
    3D人体建模的前沿探索:细数主流模型与技术进展
    Python之第六章 内置容器 --- 正则表达式
    《Java并发编程实战》第4章-对象的组合
    落单的数字
    LCM Sum (hard version)(树状数组,筛因子)
    『大模型笔记』MIT 最新的科尔莫戈洛夫-阿诺德网络(Kolmogorov-Arnold Network,KAN)简介
  • 原文地址:https://blog.csdn.net/weixin_61523879/article/details/126826225