最新消息:20210917 已从crifan.com换到crifan.org

【已解决】Mac中用vuejs把本地mysql中的数据在vue-admin-template的table列表页面展示出来

Vue crifan 827浏览 0评论
折腾:
【未解决】Mac中用vue-admin-template实现智能电力前端页面功能模块
期间,此处希望把本地mysql的数据:
在前端vuejs的模板项目vue-admin-template中的table页:
能展示出来。
去看看代码。
此处,确保postman测试api接口是正常的:
【总结】
然后用代码:
src/client/xxxClient/src/views/table/index.vue
<template>
  <div class="app-container">
    <el-table
      v-loading="listLoading"
      :data="list"
      element-loading-text="Loading"
      border
      fit
      highlight-current-row
    >
      <el-table-column align="center" label="ID" width="60">
        <template slot-scope="scope">
          <!-- {{ scope.$index }} -->
          {{ scope.row.id }}
        </template>
      </el-table-column>
      <el-table-column label="Data" width="200">
        <template slot-scope="scope">
          <span>{{ scope.row.data }}</span>
        </template>
      </el-table-column>
      <el-table-column label="Parse Result">
        <template slot-scope="scope">
          <pre>{{ scope.row.parseResult }}</pre>
        </template>
      </el-table-column>
      <!-- <el-table-column label="Pageviews" width="110" align="center">
        <template slot-scope="scope">
          {{ scope.row.pageviews }}
        </template>
      </el-table-column>
      <el-table-column class-name="status-col" label="Status" width="110" align="center">
        <template slot-scope="scope">
          <el-tag :type="scope.row.status | statusFilter">{{ scope.row.status }}</el-tag>
        </template>
      </el-table-column>
      <el-table-column align="center" prop="created_at" label="Display_time" width="200">
        <template slot-scope="scope">
          <i class="el-icon-time" />
          <span>{{ scope.row.display_time }}</span>
        </template>
      </el-table-column> -->
    </el-table>
  </div>
</template>


<script>
import { getList } from '@/api/table'


export default {
  // filters: {
  //   statusFilter(status) {
  //     const statusMap = {
  //       published: 'success',
  //       draft: 'gray',
  //       deleted: 'danger'
  //     }
  //     return statusMap[status]
  //   }
  // },
  data() {
    return {
      list: null,
      listLoading: true
    }
  },
  created() {
    this.fetchData()
  },
  methods: {
    fetchData() {
      this.listLoading = true
      getList().then(response => {
        console.log('response=%o', response)
        // this.list = response.data.items
        this.list = response.data
        this.listLoading = false
      })
    }
  }
}
</script>
src/client/xxxClient/src/api/table.js
import request from '@/utils/request'


export function getList(params) {
  // return request({
  //   url: '/vue-admin-template/table/list',
  //   method: 'get',
  //   params
  // })


  return request({
    url: 'http://localhost:8080/iec104/all',
    method: 'get'
  })
}
即可显示出来:
注:
如果把
<pre>{{ scope.row.parseResult }}</pre>
换成:
<p>{{ scope.row.parseResult }}</p>
就可以看到一行行的内容了:

转载请注明:在路上 » 【已解决】Mac中用vuejs把本地mysql中的数据在vue-admin-template的table列表页面展示出来

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
93 queries in 0.189 seconds, using 23.33MB memory