/
MethodChoice.vue
63 lines (60 loc) · 1.29 KB
/
MethodChoice.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<template>
<div>
<p>
<label for="methodoptions">I need to {{ methodType }}</label>
<select id="methodoptions" name="select" v-model="selected">
<option value="" disabled selected>...</option>
<option v-for="option in options" :key="option.desc" :value="option">
{{ option.shortDesc }}
</option>
</select>
</p>
<method-base v-show="isSelected" :urlPath="selected.name">
<span v-if="selected.name === 'length'" slot="title">Array.{{selected.name}}</span>
<span v-else slot="title">Array.{{selected.name}}()</span>
<span slot="desc" v-html="selected.desc"></span>
</method-base>
</div>
</template>
<script>
import MethodBase from './MethodBase.vue'
export default {
components: {
MethodBase
},
props: {
methodType: {
type: String,
required: false
},
options: {
type: Array,
required: true
}
},
data() {
return {
selected: ''
}
},
computed: {
isSelected() {
return this.$store.state.selectedMethod
}
},
watch: {
selected() {
this.$store.commit('selectionMethod', this.selected)
}
}
}
</script>
<style scoped>
code {
background: #eee;
padding: 3px 6px;
font-size: 16px;
border-radius: 5px;
color: #666;
}
</style>