Create a category list interface for background management items

inadmin->src->viewsCreate a new file under the folderCategoriesList.vue, enter the basic structure of vue:

// CategoriesList.vue
<template>
  <div>
      <h1>Classification list</h1>
  </div>
</template>

<script>
export default{}</script>

<style>

</style>
Copy the code

Configure a route for the new page

Import new page and configure route in admin-> SRC ->route/index.js:

Start mongodb, run Serve, and then run admin. Click the left navigation bar in your browser to see the new page.

Added category list page

Add a table to show the data and methods to get the data in the category list page:

// CategoriesList.vue
<template>
  <div>
      <h1>Classification list</h1>
      <el-table :data="tableData" style="width: 100%">
        <el-table-column prop="_id" label="ID" width="180">
        </el-table-column>
        <el-table-column prop="cateName" label="Category name" width="180">
        </el-table-column>
      </el-table>
  </div>
</template>

<script>
export default {
    data() {
        return {
            tableData: []}},methods: {
        async fecth() {
            // Get data from the server interface
            // this.$_http.get('path')}},created(){}}</script>

<style>

</style>
Copy the code

Write a server-side interface for a list of categories

In serve – > the router – > admin/index in js:

Write the AXIOS request in the category list interface

Create a new category in your browser, try it out, and everything works…

Create a category by browser: