Commit 2f7f9c8e authored by Damon's avatar Damon

refactor: 答案解释组件

parent bedd2bb3
<template> <template>
<view class="card"> <view class="card">
<u-card title="答错了" padding="10" :thumb="thumb"> <u-card :title="title" padding="10" :thumb="thumb">
<view class="u-flex content" slot="body"> <view class="u-flex content" slot="body">
<view class="lists">正确答案: {{ answer }}</view> <view class="lists">正确答案:{{ answer }}</view>
<view class="lists">解释说明:{{ explain }}</view> <view class="lists">解释说明:{{ explain }}</view>
</view> </view>
</u-card> </u-card>
...@@ -13,6 +13,10 @@ ...@@ -13,6 +13,10 @@
export default { export default {
name: 'answerSheet', name: 'answerSheet',
props: { props: {
type: {
type: String,
default: 'wrong',
},
answer: { answer: {
type: String, type: String,
default: '', default: '',
...@@ -22,13 +26,16 @@ export default { ...@@ -22,13 +26,16 @@ export default {
default: '', default: '',
}, },
}, },
computed: {
title() {
return this.type === 'right' ? '答对了' : '答错了'
}
},
data() { data() {
return { return {
thumb: 'http://pic2.sc.chinaz.com/Files/pic/pic9/202002/hpic2119_s.jpg', thumb: 'http://pic2.sc.chinaz.com/Files/pic/pic9/202002/hpic2119_s.jpg',
} }
}, }
created() {},
methods: {},
} }
</script> </script>
<style lang="scss"> <style lang="scss">
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
| 属性名 | 类型 | 默认值 | 可选值 | 说明 | | 属性名 | 类型 | 默认值 | 可选值 | 说明 |
| :--------: | :-----: | :----: | :--------: | :---------------------: | | :--------: | :-----: | :----: | :--------: | :---------------------: |
| type | String | wrong | right | 答对还是答错 |
| multiple | Boolean | false | true/false | 是否支持多选 | | multiple | Boolean | false | true/false | 是否支持多选 |
| answerList | Array | [] | - | 答案列表 **格式见下文** | | answerList | Array | [] | - | 答案列表 **格式见下文** |
......
...@@ -4,11 +4,18 @@ ...@@ -4,11 +4,18 @@
<view> <view>
<text class="title">{{title}}</text> <text class="title">{{title}}</text>
</view> </view>
<view style="margin-top: 200rpx; width: 100%;">
<answer-explanation answer="A" explain="无"></answer-explanation>
</view>
</view> </view>
</template> </template>
<script> <script>
import answerExplanation from '@/components/answer-explanation/index.vue'
export default { export default {
components: {
answerExplanation
},
data() { data() {
return { return {
title: 'Hello' title: 'Hello'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment