Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
tictactoe
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Claire 梁月彤
tictactoe
Commits
1afe1566
Commit
1afe1566
authored
Dec 02, 2019
by
liangyuetong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
加颜色
parent
3942f498
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
5 deletions
+16
-5
Square.js
src/components/Square.js
+5
-2
square.css
src/components/square.css
+9
-1
Container.js
src/routes/Container.js
+2
-2
No files found.
src/components/Square.js
View file @
1afe1566
import
React
,
{
Component
}
from
'
react
'
;
import
React
,
{
Component
}
from
'
react
'
;
import
styles
from
'
./square.css
'
;
class
Square
extends
Component
{
render
()
{
return
<
div
className
=
{
styles
.
square
}
onClick
=
{
this
.
props
.
onClick
}
><
span
className
=
{
styles
.
squareVal
}
>
{
this
.
props
.
value
}
<
/span></
div
>
;
const
value
=
this
.
props
.
value
;
// const blue = Object.assign({}, styles.blue, styles.square);
console
.
log
(
styles
.
blue
)
return
<
div
className
=
{
`
${
styles
.
square
}
${
value
===
'
x
'
?
styles
.
blue
:
value
===
'
o
'
?
styles
.
red
:
styles
.
default
}
`
}
onClick
=
{
this
.
props
.
onClick
}
><
span
className
=
{
styles
.
squareVal
}
>
{
this
.
props
.
value
}
<
/span></
div
>
;
}
}
export
default
Square
;
...
...
src/components/square.css
View file @
1afe1566
...
...
@@ -10,7 +10,15 @@
text-align
:
center
;
position
:
relative
;
}
.blue
{
background-color
:
lightblue
;
}
.red
{
background-color
:
lightpink
;
}
.default
{
margin
:
0
;
}
.squareVal
{
position
:
absolute
;
left
:
50%
;
...
...
src/routes/Container.js
View file @
1afe1566
...
...
@@ -48,7 +48,6 @@ function Container({ dispatch, con }) {
winner
:
arr
[
a
]
}
})
alert
(
`赢了~~`
)
}
}
return
winner
;
...
...
@@ -117,7 +116,7 @@ function Container({ dispatch, con }) {
title
:
'
步数
'
,
key
:
'
step
'
,
dataIndex
:
'
step
'
,
render
:
(
text
,
records
,
index
)
=>
<
div
className
=
{
styles
.
step
}
onClick
=
{()
=>
recall
(
records
,
index
)}
>
{
text
}
<
/div
>
render
:
(
text
,
records
,
index
)
=>
<
Button
className
=
{
styles
.
step
}
onClick
=
{()
=>
recall
(
records
,
index
)}
>
{
text
}
<
/Button
>
},
{
title
:
'
坐标
'
,
...
...
@@ -126,6 +125,7 @@ function Container({ dispatch, con }) {
}
]
const
chessArr
=
step
===
0
?
new
Array
(
9
).
fill
(
null
)
:
record
[
step
-
1
].
records
;
return
(
<
div
className
=
{
styles
.
container
}
>
<
div
className
=
{
styles
.
normal
}
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment