Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Yossapol
/
wds-react
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit ffb1b606
authored
Feb 25, 2019
by
GOLF
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://192.168.10.40/golfyos/wds-react
2 parents
4f1cd779
87109a12
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
216 additions
and
13 deletions
README.md
README.md
View file @
ffb1b60
...
@@ -268,19 +268,110 @@ export default class HomePage extends Component {
...
@@ -268,19 +268,110 @@ export default class HomePage extends Component {
```
```
การตั้งชื่อ class
| | |
| --------- | ---- |
| Component | |
| Template | |
| Page | |
#### Class Component
ขึ้นต้นด้วย "WDS " ตามด้วย ชื่อของ Component ที่ขึ้นต้นด้วยตัวอักษรภาษาอังกฤษตัวพิมพ์
<u>
ใหญ่
</u>
เฉพาะตัวอักษรตัวแรก
คั่นระหว่างคำด้วยตัวอักษรภาษาอังกฤษตัวพิมพ์
<u>
ใหญ่
</u>
เฉพาะตัวอักษรตัวแรก
ตามด้วยตัวอักษรภาษาอังกฤษตัวพิมพ์
<u>
เล็ก
</u>
ตามด้วยคำว่า "Component"
```
javascript
import
React
,
{
Component
,
Fragment
}
from
'react'
;
import
{
Input
,
Icon
}
from
'antd'
;
export
default
class
WDSUsernameTextfieldComponent
extends
Component
{
render
()
{
return
(
<
Input
prefix
=
{
<
Icon
type
=
"user"
style
=
{{
color
:
'rgba(0,0,0,.25)'
}}
/>} placeholder="Username" /
>
);
}
}
```
#### Class Template
ขึ้นต้นด้วย "WDS " ตามด้วย ชื่อของ Template ที่ขึ้นต้นด้วยตัวอักษรภาษาอังกฤษตัวพิมพ์
<u>
ใหญ่
</u>
เฉพาะตัวอักษรตัวแรก
คั่นระหว่างคำด้วยตัวอักษรภาษาอังกฤษตัวพิมพ์
<u>
ใหญ่
</u>
เฉพาะตัวอักษรตัวแรก
ตามด้วยตัวอักษรภาษาอังกฤษตัวพิมพ์
<u>
เล็ก
</u>
ตามด้วยคำว่า "Template"
```
javascript
import
React
,
{
Component
}
from
'react'
;
import
{
Layout
}
from
'antd'
;
import
*
as
EventConstants
from
'../../../resources/js/constants/eventConstants'
;
import
{
style
}
from
'./resources/style/jsx/footerStyle'
;
const
{
Footer
}
=
Layout
;
export
default
class
WDSFooterTemplate
extends
Component
{
constructor
(
props
)
{
super
(
props
);
this
.
state
=
{
systemFooter
:
''
};
}
render
()
{
return
<
Footer
style
=
{
style
}
>
{
this
.
state
.
systemFooter
}
<
/Footer>
;
}
}
```
#### Class Page
ขึ้นต้นด้วยตัวอักษรภาษาอังกฤษตัวพิมพ์
<u>
ใหญ่
</u>
เฉพาะตัวอักษรตัวแรก
ตามด้วยตัวอักษรภาษาอังกฤษตัวพิมพ์
<u>
เล็ก
</u>
ตามด้วยคำว่า "Page"
```
javascript
import
React
from
'react'
;
import
Axios
from
'axios'
;
import
Login
from
'../../templates/form/login/Login'
;
import
history
from
'../../history'
;
import
*
as
UrlConstants
from
'../../resources/js/constants/urlConstants'
;
import
Logo
from
'./resources/images/logo_login.png'
;
import
'./resources/style/css/login.css'
;
export
default
class
LoginPage
extends
React
.
Component
{
_login
=
async
params
=>
{
const
results
=
await
Axios
.
post
(
UrlConstants
.
URL_LOGIN
,
params
);
if
(
results
.
data
.
success
)
{
history
.
push
(
'/process'
);
}
};
render
()
{
return
(
<
div
className
=
"login"
>
<
img
src
=
{
Logo
}
className
=
"login-logo"
alt
=
"logo"
/>
<
br
/>
<
br
/>
<
br
/>
<
Login
getFormSubmitFn
=
{
this
.
_login
}
/
>
<
/div
>
);
}
}
```
-
Component
-
Template
-
Page
### Import
### Import
...
@@ -351,12 +442,125 @@ this.props.eventEmitter.removeListener()
...
@@ -351,12 +442,125 @@ this.props.eventEmitter.removeListener()
## 4. Routing
## 4. Routing
route
### Switch
Switch เป็นการทำ Route แบบเปลี่ยนทั้งหน้า เมื่อ url เปลี่ยนหน้าจอจะแสดงผลที่ตรงกับ path ที่ระบุไว้เพียงหน้าจอเดียว โดยเรียงลำดับการแสดงผลจากบนลงล่าง
```
javascript
// app.js
import
React
,
{
Component
}
from
'react'
;
import
Routing
from
'./routes/mainRoutes'
;
import
'./resources/style/css/App.css'
;
class
App
extends
Component
{
render
()
{
return
<
Routing
eventEmitter
=
{
this
.
props
.
eventEmitter
}
/>
;
}
}
export
default
App
;
```
import ไฟล์ mainRoutes.js เพื่อใช้ในการกำหนดเส้นทาง App.js
```
javascript
// mainRoutes.js
import
React
from
'react'
;
import
{
Switch
,
Route
}
from
'react-router-dom'
;
import
LoginPage
from
'../pages/login/LoginPage'
;
import
MainPage
from
'../pages/main/MainPage'
;
export
default
({
eventEmitter
})
=>
(
<
Switch
>
<
Route
exact
path
=
"/"
component
=
{
LoginPage
}
/
>
<
Route
path
=
"/login"
component
=
{
LoginPage
}
/
>
<
Route
path
=
"/process"
render
=
{
props
=>
<
MainPage
eventEmitter
=
{
eventEmitter
}
{...
props
}
/>
}
/>
<
/Switch
>
);
```
### match
match เป็นการแสดงผล component เฉพาะส่วน ซึ่งสามารถทำงานภายใต้หน้าจอหลักได้
```
javascript
// mainPage.jsx
import
React
from
'react'
;
import
{
Layout
}
from
'antd'
;
import
ContentRoutes
from
'../../routes/contentRoutes'
;
export
default
class
MainPage
extends
React
.
Component
{
render
()
{
return
(
<
Layout
style
=
{{
minHeight
:
'100vh'
}}
>
<
Header
/>
<
Sider
/>
<
Layout
>
<
Breadcrumb
/>
<
div
className
=
"content"
style
=
{{
margin
:
10
}}
>
<
ContentRoutes
match
=
{
this
.
props
.
match
}
/
>
<
/div
>
<
Footer
/>
<
/Layout
>
<
/Layout
>
);
}
}
```
import ไฟล์ contentRoutes.js เพื่อใช้ในการกำหนดเส้นทาง App.js
```
javascript
//contentRoutes.js
import
React
from
'react'
;
import
{
Switch
,
Route
}
from
'react-router-dom'
;
import
Content1
from
'../pages/content/Content1'
;
import
Content2
from
'../pages/content/Content2'
;
import
Content3
from
'../pages/content/Content3'
;
import
Home
from
'../pages/content/Home'
;
export
default
({
match
})
=>
{
return
(
<
Switch
>
<
Route
path
=
{
`
${
match
.
url
}
/home`
}
component
=
{
Home
}
/
>
<
Route
path
=
{
`
${
match
.
url
}
/content1`
}
component
=
{
Content1
}
/
>
<
Route
path
=
{
`
${
match
.
url
}
/content2`
}
component
=
{
Content2
}
/
>
<
Route
path
=
{
`
${
match
.
url
}
/content3`
}
component
=
{
Content3
}
/
>
<
/Switch
>
);
};
```
## 5. Calling API
## 5. Calling API
call
call
## 6. Default Component Property & Behavior
default
\ No newline at end of file
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment