React04 評論案例

2021-10-01 19:07:00 字數 916 閱讀 1465

效果圖:

src結構:

comments.unshift(comment);//unshift() 方法可向陣列的開頭新增乙個或更多元素,並返回新的長度

this.setstate();

}console.log(index);

let = this.state;

comments.splice(index,1);//splice()可以做到增刪改

this.setstate();

}render() = this.state;

return()}

}問題總結

react學習三 渲染評論列表案例

js打包入口檔案main.js 匯入 react包 import react from react import reactdom from react dom import commentlist from components comment1 commentlist.jsx reactdom....

React書城小案例

步驟1 api介面設定 步驟2 通過axios 設定好獲取資料的方法import axios from index.js const getbanner let initparams const getcourselist params initparams const getcourseinfo ...

react基礎事件 小案例

事件的繫結 三種方法 方法不加括號 事件帶括號會自動執行方法 普通執行事件不帶括號 this.方法 將函式改為箭頭函式 方法加括號 this.方法.bind this 用bind將當前的this傳過去 在constructor 中寫 this.方法 this.方法.bind this 事件的引數傳遞...