ant-design-vue usage record

1. When the transfer assembly to form the value (e.g. value of a need to modify the data transmitted to the back via a form), being given You can not set a form field before rendering a field associated with the value.

There are two possible reasons, one has not yet been rendered in a form on its traditional values, resulting in an error. Second redundant transfer table item by using the setting value this.setFieldsValue (value).
The first point to address: Use

	this.$nextTick(() => {
       // this.form.setFieldsValue(content);
      });

Second Solution: Remove the extra attribute

    edit(record) {
      console.log(record);
      const content = JSON.parse(JSON.stringify(record));
      delete content.id; // 删除多余的两项
      delete content.updateTime;
      this.$nextTick(() => {
        this.form.setFieldsValue(content);
      });
    },

Schematic error

2. Call a component in the js file

Since different interfaces return a status code needs to prompt the user according to the status code. Notification component used here, which does not interrupt the operation of the lightweight user prompt manner.
prompt

import axios from "axios";
import router from "../router";
import { notification } from "ant-design-vue";

/* 请求拦截,省略 */

/* 响应拦截 */
axios.interceptors.response.use(
  response => response,
  err => {
    if (err.response) {
      switch (err.response.status) {
        case 401:
          notification.error({
            message: "401",
            description: "抱歉,未授权"
          });
          localStorage.removeItem("token");
          router.replace("/login");
          break;
        default:
          notification.error({
            message: err.response.status,
            description: "抱歉,出错了"
          });
          break;
      }
    }
  }
);
export default axios;

First record here friends ~ ~
https://github.com/Gesj-yean/vue-demo-collection documented use more outstanding plug-ins. Students have time to look at my top blog can thank you very much.

Published 27 original articles · won praise 4 · Views 2827

Guess you like

Origin blog.csdn.net/qq_39083496/article/details/100574885