Javascript 在ios浏览器环境中使用vuejs开发无法获得该值
我用vuejs组件开发了倒计时组件,在pc和Andrews环境下是正常的,但是在ios环境下因为不能得到realcount计算不出来,NaNJavascript 在ios浏览器环境中使用vuejs开发无法获得该值,javascript,webpack,vue.js,vuejs2,Javascript,Webpack,Vue.js,Vuejs2,我用vuejs组件开发了倒计时组件,在pc和Andrews环境下是正常的,但是在ios环境下因为不能得到realcount计算不出来,NaN <template> <div class="coutpage"> <div class="countheader"> </div> <ul class="countdowmlist" v-if="!countdowndata.over"> <li v-text="co
<template>
<div class="coutpage">
<div class="countheader">
</div>
<ul class="countdowmlist" v-if="!countdowndata.over">
<li v-text="countdowndata.days"></li>
<li>天</li>
<li v-text="countdowndata.hours"></li>
<li>时</li>
<li v-text="countdowndata.minus"></li>
<li>分</li>
<li v-text="countdowndata.second"></li>
<li>秒</li>
</ul>
<div class="isover" v-if="countdowndata.over">
时间到
</div>
</div>
</template>
<script type="text/ecmascript-6">
export default {
name: 'Countdown',
props: [ 'endDate' ],
data () {
return {
countdowndata: {
days: '0',
hours: '0',
minus: '0',
second: '0',
realcount: '0',
over: false
},
interval: {}
}
},
created () {
const counttime = new Date(this.endDate).getTime() - new Date().getTime()
if (counttime < 0) {
clearInterval(this.interval)
return
}
this.countdowndata.realcount = Math.floor(counttime / 1000)
const _this = this
this.interval = setInterval(function () {
_this.getCount()
}, 1000)
},
methods: {
getCount () {
var time = this.countdowndata.realcount
if (time <= 0) {
clearInterval(this.interval)
this.countdowndata.over = true
return
}
var days = Math.floor(time / 60 / 60 / 24)
var hours = Math.floor((time - days * 60 * 60 * 24) / 60 / 60)
var minus = Math.floor((time - days * 60 * 60 * 24 - hours * 60 * 60) / 60)
var second = Math.floor((time - days * 60 * 60 * 24 - hours * 60 * 60 - minus * 60))
hours = hours < 10 ? ('0' + hours) : hours
minus = minus < 10 ? ('0' + minus) : minus
second = second < 10 ? ('0' + second) : second
this.countdowndata.days = days
this.countdowndata.hours = hours
this.countdowndata.minus = minus
this.countdowndata.second = second
this.countdowndata.realcount--
}
}
}
</script>
- 天李>
- 时李>
- 分李>
- 秒李>
时间到
导出默认值{
名称:'倒计时',
道具:['endDate'],
数据(){
返回{
倒计时数据:{
天:“0”,
小时数:“0”,
减:“0”,
第二个:“0”,
realcount:'0',
结束:错
},
间隔:{}
}
},
创建(){
const counttime=new Date(this.endDate).getTime()-new Date().getTime()
如果(计数时间<0){
clearInterval(this.interval)
返回
}
this.countdowndata.realcount=Math.floor(counttime/1000)
常数this=this
this.interval=setInterval(函数(){
_这是getCount()
}, 1000)
},
方法:{
getCount(){
var time=this.countdowndata.realcount
如果(时间考虑使用moment.js进行日期和时间操作