亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

這里為什么會報錯?

這里為什么會報錯?

Uncaught?TypeError:?Cannot?read?property?'0'?of?null<!DOCTYPE?html>?<html>?<head> ?????<meta?charset="UTF-8">????? ?????<meta?name="viewport"?content="width=device-width,?initial-scale=1.0">????? ?????<meta?http-equiv="X-UA-Compatible"?content="ie=edge">????? ?????<title>Document</title>?</head>? <body>????? ?????<textarea?id="show"?spellcheck="true">#?豬</textarea>????? ?????<input?type="file"?id="file1">????? ?????<input?type="button"?id="btn"?onclick="rec()"?value="轉換">????? ?????<script> ??????????????var?filein?=?document.getElementById('file1'),????????????? ??????????????showbox?=?document.getElementById('show');????????? ??????????????filein.addEventListener('change',?function?()?{????????????? ??????????????var?file?=?filein.files[0];????????????? ??????????????var?reader?=?new?FileReader();????????????? ??????????????reader.onload?=?function?(e)?{????????????????? ??????????????????showbox.innerHTML?=?data;????????????? ??????????????};????????????? ??????????????reader.readAsText(file,?'utf-8');????????? ??????????????});????????? ??????????????function?rec()?{????????????? ??????????????var?textarea?=?document.getElementById('show');????????????? ??????????????textarea.innerHTML?=?main(textarea.value);?//可以寫入字符串????????? ??????????????}????????? ??????????????function?main(evt)?{????????????? ??????????????var?char?=?evt.split("\n");????????????? ??????????????var?matchArry;????????????? ??????????????var?html?=?'';????????????? ??????????????var?len?=?char.length;????????????? ??????????????for?(var?i?=?0;?i?<?len;?i++)?{????????????????? ??????????????//數組儲存模板????????????????? ??????????????matchArry?=?char[i].match(/^#\s/);?//切割成[""]????????????????? ??????????????if?(matchArry[0])?{????????????????????? ??????????????switch?(matchArry[0])?{?//輸入了空的字符串和不匹配字符串則會報錯??? ??????????????case?'#?':???????????????????????????? ???????????????html?+=?'<h1>'?+?add(char[i].substring(2))?+?'</h1>';????????????????????????????? ???????????????break;?????????????????????????default:????????????????????????????? ???????????????break;?????????????????????}????????????????? ???????????????}?else?{????????????????????? ???????????????html?+=?'<p>'?+?add(char[i])?+?'</p>';????????????????? ???????????????}????????????? ???????????????}????????????? ???????????????return?html;????????? ???????????????}????????? ???????????????function?add(str)?{????????????? ???????????????str?=?str.replace(/\s/g,?'&nbsp;' ???????????????);????????????? ???????????????return?str;????????? ???????????????}????? ????</script>? </body>? </html>
查看完整描述

1 回答

?
Ohara_Setsuna

TA貢獻2條經驗 獲得超1個贊

求大神帶飛

查看完整回答
反對 回復 2019-02-21
  • 1 回答
  • 0 關注
  • 926 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號