• Vue首次使用Element


    index.vue

    这里加入的样式

    1. <template>
    2. <el-table :data="tableData" style="width: 100%">
    3. <el-table-column prop="id" label="ID" width="180" />
    4. <el-table-column prop="name" label="Name" width="180">
    5. <template #default="scope">
    6. <router-link :to="{ name: 'about', query: { id: scope.row.id } }">
    7. {{ scope.row.name }}</router-link>
    8. </template>
    9. </el-table-column>
    10. <el-table-column prop="img" label="图片">
    11. <template #default="scope">
    12. <el-image style="width: 100px; height: 100px" :src="scope.row.img" fit="contain"
    13. :preview-src-list="srcList" />
    14. </template>
    15. </el-table-column>
    16. </el-table>
    17. </template>
    18. <script lang="ts" setup>
    19. import { CaretBottom } from '@element-plus/icons-vue'
    20. interface User {
    21. date: string
    22. name: string
    23. address: string
    24. }
    25. const srcList = [
    26. 'https://fuss10.elemecdn.com/a/3f/3302e58f9a181d2509f3dc0fa68b0jpeg.jpeg',
    27. 'https://fuss10.elemecdn.com/1/34/19aa98b1fcb2781c4fba33d850549jpeg.jpeg',
    28. 'https://fuss10.elemecdn.com/0/6f/e35ff375812e6b0020b6b4e8f9583jpeg.jpeg',
    29. 'https://fuss10.elemecdn.com/9/bb/e27858e973f5d7d3904835f46abbdjpeg.jpeg',
    30. 'https://fuss10.elemecdn.com/d/e6/c4d93a3805b3ce3f323f7974e6f78jpeg.jpeg',
    31. 'https://fuss10.elemecdn.com/3/28/bbf893f792f03a54408b3b7a7ebf0jpeg.jpeg',
    32. 'https://fuss10.elemecdn.com/2/11/6535bcfb26e4c79b48ddde44f4b6fjpeg.jpeg',
    33. ]
    34. const tableRowClassName = ({
    35. row,
    36. rowIndex,
    37. }: {
    38. row: User
    39. rowIndex: number
    40. }) => {
    41. if (rowIndex === 1) {
    42. return 'warning-row'
    43. } else if (rowIndex === 3) {
    44. return 'success-row'
    45. }
    46. return ''
    47. }
    48. const tableData = [
    49. {
    50. "id": 1,
    51. "name": "小米手机",
    52. "img": "https://cdn.cnbj1.fds.api.mi-img.com/product-images/blackshark5bj8dh4/2833.jpg"
    53. },
    54. {
    55. "id": 2,
    56. "name": "小米手机",
    57. "img": "https://cdn.cnbj1.fds.api.mi-img.com/product-images/blackshark5bj8dh4/2833.jpg"
    58. },
    59. {
    60. "id": 3,
    61. "name": "小米手机",
    62. "img": "https://cdn.cnbj1.fds.api.mi-img.com/product-images/blackshark5bj8dh4/2833.jpg"
    63. }
    64. ]
    65. </script>
    66. <style scoped>
    67. .item {
    68. margin-top: 10px;
    69. margin-right: 40px;
    70. }
    71. .el-dropdown {
    72. margin-top: 1.1rem;
    73. }
    74. </style>

    app.vue

    这里面加入的容器的布局

    1. <template>
    2. <div class="common-layout">
    3. <el-container>
    4. <el-header class="header">Header</el-header>
    5. <el-container>
    6. <el-aside width="200px" class="shouye"> <!--使用 router-link 组件进行导航 -->
    7. <!--通过传递 `to` 来指定链接 -->
    8. <!--`<router-link>` 将呈现一个带有正确 `href` 属性的 `<a>` 标签-->
    9. <router-link to="/">首页</router-link><br />
    10. <router-link to="/login">登录页面</router-link></el-aside>
    11. <el-main>
    12. <!-- 路由出口 -->
    13. <!-- 路由匹配到的组件将渲染在这里 -->
    14. <router-view></router-view></el-main>
    15. </el-container>
    16. </el-container>
    17. </div>
    18. </template>
    19. <style>
    20. .header{
    21. background-color: aqua;
    22. }
    23. .shouye{
    24. background-color:aquamarine;
    25. }
    26. </style>

    其他修改地方

    这里面增加了

  • 相关阅读:
    制作一个简单HTML宠物猫网页(HTML+CSS)
    A-Level经济例题解析及练习Budget Constraint
    【基础】性能测试,从0到实战(手把手教,非常实用)
    策略模式在数据接收和发送场景的应用
    电脑技巧:PrivaZer电脑清理工具介绍
    随机森林random forest和Stepwise Clustered Ensemble (SCE)
    2303. 计算应缴税款总额
    Springboot中的@Import注解~
    Nginx + keepalived 集群搭建
    ThreadLocal 源码分析
  • 原文地址:https://blog.csdn.net/qq_59102081/article/details/125484104