Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
study
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
Damon
study
Commits
9a443144
Commit
9a443144
authored
Jul 07, 2021
by
Damon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 答题卡组件
parent
b8201666
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
150 additions
and
0 deletions
+150
-0
index.vue
src/components/answer-sheet/index.vue
+70
-0
readme.md
src/components/answer-sheet/readme.md
+80
-0
No files found.
src/components/answer-sheet/index.vue
0 → 100644
View file @
9a443144
<
template
>
<view
class=
"u-flex sheet"
>
<view
class=
"u-flex u-col-center lists"
v-for=
"(item, index) in lists"
:key=
"index"
@
click=
"select(index)"
>
<view
class=
"icons"
>
<u-icon
name=
"checkmark-circle"
:color=
"item.checked ? '#409eff' : inherit"
size=
"40"
></u-icon>
</view>
<view
class=
"text"
>
{{
item
.
text
}}
</view>
</view>
</view>
</
template
>
<
script
>
export
default
{
name
:
'answerSheet'
,
props
:
{
answerList
:
{
type
:
Array
,
default
:
[]
},
multiple
:
{
type
:
Boolean
,
default
:
false
,
},
},
data
()
{
return
{
lists
:
[]
}
},
created
()
{
this
.
lists
=
this
.
answerList
?
this
.
answerList
.
map
((
v
)
=>
{
v
.
checked
=
false
return
v
})
:
[]
},
methods
:
{
select
(
index
)
{
if
(
!
this
.
multiple
)
{
this
.
lists
.
forEach
(
v
=>
{
v
.
checked
=
false
})
}
this
.
$set
(
this
.
lists
[
index
],
'checked'
,
!
this
.
lists
[
index
].
checked
)
const
lists
=
this
.
lists
.
filter
(
v
=>
v
.
checked
)
this
.
$emit
(
'change'
,
lists
)
}
},
}
</
script
>
<
style
lang=
"scss"
>
.sheet
{
flex-flow
:
column
;
.lists
{
padding
:
10rpx
0
;
width
:
100%
;
.icons
{
padding
:
5rpx
20rpx
0rpx
20rpx
;
}
.text
{
flex
:
1
;
}
}
}
</
style
>
src/components/answer-sheet/readme.md
0 → 100644
View file @
9a443144
## 答题卡
```
答题卡组件,用于考试选择答案,可以单选、多选。
```
## API
### Props
| 属性名 | 类型 | 默认值 | 可选值 | 说明 |
| :--------: | :-----: | :----: | :--------: | :---------------------: |
| multiple | Boolean | false | true/false | 是否支持多选 |
| answerList | Array |
[]
| - | 答案列表
**格式见下文**
|
### answerList 格式
```
json
[
{
"text"
:
""
//
答案描述
}
]
```
### Events
| 事件称名 | 说明 | 返回值 |
| :------: | :------------: | :-------------------------: |
| @change | 改变答案后触发 | 已选答案数组
**格式见下文**
|
```
json
[
{
"text"
:
""
//
答案描述
}
]
```
## 组件用法
### 基础用法
```
html
<answer-sheet
:answerList=
"lists"
:multiple=
"true"
@
change=
"answerChange"
></answer-sheet>
```
```
javascript
import
answerSheet
from
'@/components/answer-sheet/index.vue'
export
default
{
components
:
{
answerSheet
,
},
data
()
{
return
{
lists
:
[
{
text
:
'A.系好安全带'
,
},
{
text
:
'B.穿好工作服'
,
},
{
text
:
'C.换上绝缘服'
,
},
],
}
},
methods
:
{
// 已选答案
answerChange
(
event
)
{
console
.
log
(
'event'
,
event
)
},
},
}
```
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