You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
after you create reactJS app, cd to project folder, then run :
yarn add antd
use antd
修改 src/App.css,在文件顶部引入 antd/dist/antd.css。
@import '~antd/dist/antd.css';
http request from JS
// submit form data to apifetch("http://10.192.83.42:9000/announcementPublish",{method: 'POST',headers: {'Accept': 'application/json','Content-Type': 'application/json',},body: JSON.stringify(values)}).then(res=>res.json()).then((result)=>{if(result.err){alert("有错误发生,发布失败!!");}else{alert("公告发布成功");this.props.form.resetFields();}},// Note: it's important to handle errors here// instead of a catch() block so that we don't swallow// exceptions from actual bugs in components.(error)=>{alert(error);})
button click -> javascript
const t_delete_page_html = `
<buttononclick="deleteEvent()">删除当前活动</button><script>functiondeleteEvent(){// submit form data to apifetch(window.location.origin+"/"+"deleteaccrecharge/"+{{.Game}},{method: 'POST',headers: {'Accept': 'application/json','Content-Type': 'application/json',},body: "{}",}).then(res=>res.json()).then((result)=>{if(result.err){alert(result.err);}else{// to reset pagewindow.location.reload(true);}},// Note: it's important to handle errors here// instead of a catch() block so that we don't swallow// exceptions from actual bugs in components.(error)=>{alert(error);})}</script>
`
form submit -> javascript
const t_add_page_html = `
<formname="form_event" onsubmit="addEvent(); return false;"><label>时间格式(北京时间): 2016010215</label><br><label>活动开始时间</label><br><inputtype="text" id="id_starttime" name="starttime" maxlength="10" placeholder="1970010208"><br><label>统计截止时间</label><br><inputtype="text" id="id_deadline" name="deadline" maxlength="10" placeholder="1970010214"><br><label>活动结束时间</label><br><inputtype="text" id="id_endtime" name="endtime" maxlength="10" placeholder="1970010220"><br><br><inputtype="submit" value="发布累冲活动"></form><script>functionisNumeric(num){return!isNaN(num)}functionaddEvent(){starttime=document.form_event.elements["starttime"].valuedeadline=document.form_event.elements["deadline"].valueendtime=document.form_event.elements["endtime"].valueif(starttime.length<10||deadline.length<10||endtime.length<10){alert("请填写完整时间");return;}if(!isNumeric(starttime)||!isNumeric(deadline)||!isNumeric(endtime)){alert("时间不能包含非数字");return;}leturl=window.location.origin+"/publishaccrecharge/"+{{.Game}}+"/"+starttime+"/"+deadline+"/"+endtimefetch(url,{method: 'POST',headers: {'Accept': 'application/json','Content-Type': 'application/json',},body: "{}",}).then(res=>res.json()).then((result)=>{if(result.err){alert(result.err);}else{// to reset pagewindow.location.reload(true);}},// Note: it's important to handle errors here// instead of a catch() block so that we don't swallow// exceptions from actual bugs in components.(error)=>{alert(error);})}</script>
`
get the content of a file
<!DOCTYPE html><html><title>
get file content test
</title><body><p>Upload your file</p><script>asyncfunctionreadText(event){constfile=event.target.files.item(0)consttext=awaitfile.text();console.log(text);// document.getElementById("output").innerText = text}</script><inputtype="file" onchange="readText(event)" /><!-- <pre id="output"></pre> --></body></html>