Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/445.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript mui数据表示例不';t呈现示例代码_Javascript_Reactjs_Mui Datatable - Fatal编程技术网

Javascript mui数据表示例不';t呈现示例代码

Javascript mui数据表示例不';t呈现示例代码,javascript,reactjs,mui-datatable,Javascript,Reactjs,Mui Datatable,新的反应和尝试学习MUI数据表。库中给定的示例代码不会在浏览器中呈现,我看到的只是一个空页面。控制台显示零错误 我的HTML: <!DOCTYPE html> <head> <title>MUIDatables Example</title> <meta name="viewport" content="width=device-width, initial-scale=1"> &

新的反应和尝试学习MUI数据表。库中给定的示例代码不会在浏览器中呈现,我看到的只是一个空页面。控制台显示零错误

我的HTML:

<!DOCTYPE html>
    <head>
        <title>MUIDatables Example</title>
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500">        
    </head>
    <body>
            <div id="root"></div>
        </body>
        <script src="Index0.js" type="text/jsx"></script>
</html>

MUIDatables示例
除非指定了“type=“text/jsx”,否则控制台中将出现有关CORS和import语句的错误。我使用的是节点http请求服务器,它确实加载了当前目录中的各种文件。目前,控制台没有显示任何错误

JS:

从“React”导入React;
从“react dom”导入react dom;
从“mui数据表”导入MUIDataTable;
类应用程序扩展了React.Component{
render(){
常量列=[“姓名”、“职务”、“位置”、“年龄”、“薪水”];
常数数据=[
[“Gabby George”,“业务分析师”,“明尼阿波利斯”,30,“100000美元],
[“艾登·劳埃德”,“商业顾问”,“达拉斯”,55,“$200000”]
//省略其他样本数据
];
常量选项={
filterType:“下拉列表”,
响应:“滚动”
};
返回(
);
}
}
render(,document.getElementById(“根”));

您的代码似乎正常。只需在末尾添加一行:导出默认应用程序我复制/粘贴您的代码并运行它。它完美地展示了桌子

import React, {useState, useEffect} from 'react';
import axios from 'axios';

function EditStudentDetails() {
    const [post, setPost] = useState({});
    const id = 1;

    const handleChange = ({target}) => {
        const {name, value} = target;
        setPost({...post, [name]: value});
        console.log(post);
    };

    const handleSubmit = async e => {
        e.preventDefault();

        const editDataById = async () => {
            try {
                const response = await axios.put(`https://jsonplaceholder.typicode.com/posts/${id}`, {
                    method: 'PUT',
                    body: JSON.stringify({
                        id: id,
                        title: post.title,
                        body: post.body,
                        userId: 1
                    }),
                    headers: {
                        "Content-type": "application/json; charset=UTF-8"
                    }
                })
                    .then(response => response.json())
                    .then(json => console.log(json));
                // latestEdit(response.data);
                console.warn(response.data);
            } catch (error) {
                console.warn(error);
            }
        };
        editDataById();
    };
    return (
        <div className='container'>
            <div className='row'>
                <div className='col-4'>
                    <form onSubmit={handleSubmit}>
                        <div className="form-group">
                            <label htmlFor="name">Title</label>
                            <input type="text" name='title' value={post.title} onChange={handleChange}
                                   className="form-control" id="title"/>
                        </div>
                        <div className="form-group">
                            <label htmlFor="position">Body</label>
                            <input type="text" name='body' value={post.body}
                                   onChange={handleChange} className="form-control" id="body"/>
                        </div>
                        <button type="submit" className="btn btn-primary">Submit</button>
                    </form>
                </div>
            </div>
        </div>
    )
}

export default EditStudentDetails;
import React,{useState,useffect}来自“React”;
从“axios”导入axios;
函数EditStudentDetails(){
const[post,setPost]=useState({});
常数id=1;
常量handleChange=({target})=>{
常量{name,value}=target;
setPost({…post[name]:value});
控制台日志(post);
};
const handleSubmit=async e=>{
e、 预防默认值();
const editdatabyd=async()=>{
试一试{
const response=等待axios.put(`https://jsonplaceholder.typicode.com/posts/${id}`{
方法:'放',
正文:JSON.stringify({
id:id,
标题:post.title,
body:post.body,
用户ID:1
}),
标题:{
“内容类型”:“应用程序/json;字符集=UTF-8”
}
})
.then(response=>response.json())
.then(json=>console.log(json));
//latestEdit(response.data);
控制台。警告(响应。数据);
}捕获(错误){
控制台。警告(错误);
}
};
editDataById();
};
返回(
标题
身体
提交
)
}
导出默认EditStudentDetails;
import React, {useState, useEffect} from 'react';
import axios from 'axios';

function EditStudentDetails() {
    const [post, setPost] = useState({});
    const id = 1;

    const handleChange = ({target}) => {
        const {name, value} = target;
        setPost({...post, [name]: value});
        console.log(post);
    };

    const handleSubmit = async e => {
        e.preventDefault();

        const editDataById = async () => {
            try {
                const response = await axios.put(`https://jsonplaceholder.typicode.com/posts/${id}`, {
                    method: 'PUT',
                    body: JSON.stringify({
                        id: id,
                        title: post.title,
                        body: post.body,
                        userId: 1
                    }),
                    headers: {
                        "Content-type": "application/json; charset=UTF-8"
                    }
                })
                    .then(response => response.json())
                    .then(json => console.log(json));
                // latestEdit(response.data);
                console.warn(response.data);
            } catch (error) {
                console.warn(error);
            }
        };
        editDataById();
    };
    return (
        <div className='container'>
            <div className='row'>
                <div className='col-4'>
                    <form onSubmit={handleSubmit}>
                        <div className="form-group">
                            <label htmlFor="name">Title</label>
                            <input type="text" name='title' value={post.title} onChange={handleChange}
                                   className="form-control" id="title"/>
                        </div>
                        <div className="form-group">
                            <label htmlFor="position">Body</label>
                            <input type="text" name='body' value={post.body}
                                   onChange={handleChange} className="form-control" id="body"/>
                        </div>
                        <button type="submit" className="btn btn-primary">Submit</button>
                    </form>
                </div>
            </div>
        </div>
    )
}

export default EditStudentDetails;