我想要什么?
点击播放按钮时倒计时
代码
我使用vuejs和vuerx来做到这一点。这是我的代码
<script>
/* eslint-disable */
import { Observable, Subscription } from 'rxjs'
export default {
data() {
return {
energy: 12
}
},
domStreams: ["play$"],
subscriptions() {
const energy$ = Observable.interval(250)
.fromEvent(play$, 'click')
.startWith(this.energy)
.scan(time => time - 1)
.takeWhile(time => time > 0)
return {
energy$
}
}
}
</script>
我的HTML
<template>
<div>
<button @click="play$">Play</button>
<input type="text" v-model="energy">
<br>
<h1>{{ energy$ }}</h1>
</div>
</template>
错误消息: