Java教程

Ant Design Pro 基本语法使用(JavaScript版)

本文主要是介绍Ant Design Pro 基本语法使用(JavaScript版),对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

组件的定义

const FirmwareList = () => 
{
//整个页面所有的代码
};
export default FirmwareList;

组件的引入

import { Upload, Form, message, Button, Row, Col } from 'antd';
import { UploadOutlined } from '@ant-design/icons';
import { useState, useRef, useEffect } from 'react';
import { useIntl } from 'umi';
import { PageContainer } from '@ant-design/pro-layout';
import ProTable from '@ant-design/pro-table';
import ProForm, { ProFormText, ModalForm, ProFormSelect } from '@ant-design/pro-form';
import { setEquipmentWorkMode } from '@/services/equipment/equipment';

数组变量带默认值的创建

const [columnsStateMap, setColumnsStateMap] = useState({
  jsonData: {
    show: false,
  },
});

bool变量创建和赋值

const [showWorkModeVisible, setShowWorkModeVisible] = useState(false);
赋值,showWorkModeVisible为const不能进行赋值
setShowWorkModeVisible(true);

string变量创建和赋值

const [deviceIdState, setDeviceIdState] = useState(String);
setDeviceIdState('123456');

数组变量创建和赋值

const [fileListState, setFileListState] = useState([]);
//这个有些区别,通过fileListState赋值就可以
fileListState.push(file);
//删除数组里的内容
const remove = (file) => {
  try {
    const index = fileListState.indexOf(file);
    const newFileList = fileListState.slice();
    newFileList.splice(index, 1);
    setFileListState(newFileList), console.log(file);
    console.log(file);
  } catch (error) {
    message.error(error);
    return false;
  }
};
这篇关于Ant Design Pro 基本语法使用(JavaScript版)的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!