第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

為什么日期函數(shù)沒有返回我預(yù)期的輸出?

為什么日期函數(shù)沒有返回我預(yù)期的輸出?

SMILET 2021-10-14 13:19:39
我正在構(gòu)建簡短的 Web 應(yīng)用程序,并使用 axios.js 將數(shù)據(jù)發(fā)送到數(shù)據(jù)庫。但是,當(dāng)我從數(shù)據(jù)庫中獲取日期時(shí),會(huì)呈現(xiàn)完整的日期,而我只希望 getDate()、getMonth() 和 getFullYear() 起作用,但它們似乎不起作用。這是 Windows 7 本地主機(jī)服務(wù)器。我已經(jīng)厭倦了用不同的方式稱呼它。function itemTemplate(item) {  return `<li class="list-group-item list-group-item-action d-flex align-items-center justify-content-between"   style = "background-color: #cff0cc;    color: #498a17;    font-family: 'Kite One', sans-serif;">  <span class="item-text">Date: ${item.date.getDate()} / ${item.date.getMonth() +    1} / ${item.date.getFullyear()} - ${item.text}</span>  <div>  <button data-id="${    item._id  }" class="edit-me btn btn-primary btn-sm" style="background-color: darkgrey;border-color: grey;"><i class="fa fa-edit" style="width: 10px;"></i></button>  <button data-id="${    item._id  }" class="delete-me btn btn-danger btn-sm"><i class="fa fa-minus-circle" aria-hidden="true" style="width: 10px;"></i>  </button>  </div>  </li>`;}// Initial Page Load Renderlet ourHTML = items  .map(function(item) {    return itemTemplate(item);  })  .join("");document.getElementById("item-list").insertAdjacentHTML("beforeend", ourHTML);// Create Featurelet createField = document.getElementById("create-field");let createdDate = new Date();document.getElementById("create-form").addEventListener("submit", function(e) {  e.preventDefault();  axios    .post("/create-item", { text: createField.value, date: createdDate })    .then(function(response) {      // Create the HTML for a new item      document        .getElementById("item-list")        .insertAdjacentHTML("beforeend", itemTemplate(response.data));      createField.value = "";      createField.focus();    })    .catch(function() {      res.send("Please try again later.");    });});預(yù)期的是,這三個(gè)日期函數(shù)的工作,但錯(cuò)誤消息顯示“item.date”在第 6 行未定義
查看完整描述

1 回答

  • 1 回答
  • 0 關(guān)注
  • 128 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)