【页面案例汇总】微信小程序考试成绩页面

  1. 在pages文件夹中创建ExamResult.vue文件

  2. 编写ExamResult.vue代码如下:

<template>
  <div class="exam-result">
    <h1>考试成绩单</h1>
    <table>
      <thead>
        <tr>
          <th>姓名</th>
          <th>学号</th>
          <th>语文成绩</th>
          <th>数学成绩</th>
          <th>英语成绩</th>
          <th>总成绩</th>
        </tr>
      </thead>
      <tbody>
        <tr v-for="result in results" :key="result.id">
          <td>{{result.name}}</td>
          <td>{{result.id}}</td>
          <td>{{result.chinese}}</td>
          <td>{{result.math}}</td>
          <td>{{result.english}}</td>
          <td>{{result.total}}</td>
        </tr>
      </tbody>
    </table>
  </div>
</template>

<script>
export default {
  data() {
    return {
      results: [
        { id: 001, name: '小明', chinese: 90, math: 80, english: 85, total: 255 },
        { id: 002, name: '小红', chinese: 85, math: 90, english: 75, total: 250 },
        { id: 003, name: '小刚', chinese: 80, math: 75, english: 95, total: 250 },
        { id: 004, name: '小美', chinese: 70, math: 90, english: 85, total: 245 },
        { id: 005, name: '小强', chinese: 75, math: 85, english: 80, total: 240 }
      ]
    }
  }
}
</script>

<style>
.exam-result {
  max-width: 800px;
  margin: 0 auto;
  padding: 30px;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 20px;
  font-size: 16px;
}

th, td {
  border: 1px solid #ddd;
  padding: 8px;
  text-align: center;
}

th {
  background-color: #eee;
}
</style>
  1. 运行uni-app项目,在首页添加一个跳转链接到ExamResult页面
<template>
  <view class="home">
    <text class="title">欢迎来到考试系统</text>
    <button class="btn" @click="gotoExamResult">查看成绩单</button>
  </view>
</template>

<script>
export default {
  methods: {
    gotoExamResult() {
      uni.navigateTo({
        url: '/pages/ExamResult/ExamResult'
      })
    }
  }
}
</script>

<style>
.home {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  height: 100vh;
}

.title {
  font-size: 24px;
  margin-bottom: 20px;
}

.btn {
  padding: 10px 20px;
  font-size: 16px;
  border-radius: 4px;
  background-color: #0d6efd;
  color: #fff;
  border: none;
  cursor: pointer;
}
</style>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值