原创 學習React (1) - VS Code裏創立react app

先介紹什麼是React: React is a JavaScript library for building user interfaces. React is a library and not a framework. Re

原创 學習React(26) - Forwarding Refs

Left forwarding is a technique for automatically passing a ref through a component to one of its children. 在上一篇的博客中

原创 學習React(15) - 列表渲染 (list rendering)

在做網站時,大部分時候我們都需要在網址上做列表,比如說姓名列表等。那麼在React裏,應該如何實現這個功能呢?那就請看這篇博客吧! 在src文件夾下面創建一個名爲Namelist.js 文件,下面是代碼: // Namelist.

原创 Java 習題 (3)

題目: 編寫一個程序,讓它含有本章所定義的storage() 方法的代碼段,並調用之。 解答: 先把storage() 方法代碼寫出來: int storage(String s) { return s.length()

原创 學習React(9) - props 的用法在class component

上一篇文章,提到如果用JSX格式來用props,應該怎麼用。現在這一篇是寫在class component裏應該如何使用props呢。還是一樣,在src 文件夾裏創建一個Testprops.js文件,代碼如下: // Testpr

原创 學習React(8) - props的用法在JSX格式

這篇都是用JSX格式來寫的,如果有哪裏有錯誤,就請指出來吧! 先上代碼,然後再根據代碼來講解一下。還是一樣,在src 文件包裏,創建一個文件,博主就命名爲Testprops.js了 // Testprops.js 文件 impor

原创 學習React(11) - State 的用法在class 中

下面是列舉State 和 props的比較 props state props get passed to the component state is managed within the component

原创 學習React(21) - Updating 生命週期方法介紹

static getDerivedStateFromProps(props, state), 這個方法is called every time a component is re-rendered. 這個方法返回either

原创 Java 習題 (5)

題目: 編寫一個程序,展示無論你創建了某個特定類的多少個對象,這個類中的某個特定的static域只有一個實例。 解答: public class chapterOne { static int i = 1; pu

原创 Java 習題(7)

題目: 將 AllTheColorsOfTheRainbow 這個示例改寫成一個程序,然後編譯,運行。 解答: 先把 AllTheColorsOfTheRainbow 的程序段寫出來: class AllTheColorsOfTh

原创 Java 習題 (4)

題目: 將 Incrementable 的代碼段改寫成一個完整的可運行程序。 解答: 先提供Incrementable 代碼段: class StaticTest { static int i = 47; } class

原创 學習React(2) - 用react 來寫Hello World

在上一篇的學習React(1) 中已經介紹如何在VS Code中用react, 那麼現在就將展示如何用react來寫Hello World. 第一步: 先得在src文件夾下,創建一個js文件名, 博主就將這個文件名命名爲:Hell

原创 學習React (3) - 如何用Jumbotron

已經學會了怎麼用React來寫Hello World, 那麼下一步就開始學習React那些組件。現在就先講講Jumbotron. 這個Jumbotron 大部分用在bootstrap裏面的,採用官方的解釋什麼是Jumbotron:

原创 學習React(4) - 文檔結構介紹

博主忘記介紹當在VS Code安裝好React 之後,會出現三個文件包和四個文件,沒有介紹。現在博主就補回來,然後在下面會介紹。 package.json 文件: This file contains the dependenc

原创 學習React(7) - JSX

在上一篇的學習React(6) - Class 組件(Component) 中,有寫到用JSX格式,和沒有用到JSX格式,那麼現在就來總結一下JSX的不同之處: class 變成 className for 變成 htmlFor