-
-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathCounterJS.js
67 lines (63 loc) · 1.42 KB
/
CounterJS.js
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
64
65
66
67
import { mapState } from 'vuex';
/**
* @module CounterJS
* @vue-prop {Number} superLongPropNameToCheckWidthStyle
* @vue-prop {Number} initialCounter
* @vue-prop {Number} [step=1] Step
* @vue-data {Number} counter - Current counter's value
* @vue-computed {Array.<String>} fooList - A list of foo
* @vue-computed {Array.<String>} barList - A list of bar
* @vue-computed {String} message A message
* @vue-slot #header This is a header slot
*/
export default {
name: 'CounterJS',
props: {
initialCounter: { type: Number, required: true },
step: { type: Number, default: 1 },
},
data() {
return {
counter: this.initialCounter,
};
},
computed: {
...mapState({
fooList: state => state.$_foo.fooList,
barList: state => state.$_foo.barList,
}),
message() {
return `Counter: ${this.counter}`;
},
},
methods: {
/**
* Increment counter.
*/
increment() {
this.counter += this.step;
},
/**
* Decrement counter.
*/
decrement() {
this.counter -= this.step;
},
/**
* Show a dialog displaying counter value.
* @param {Number} counter - Counter value
*/
showDialog(counter) {
alert(`Counter value is ${counter}.`);
},
},
/**
* Counter.vue `created` hook.
*/
created() {
console.info('Counter.vue: created()');
},
mounted() {
console.info('Counter.vue: mounted()');
},
};