Merge pull request #199 from richex-cn/fix-time-comp-update
fix Time component can't update when time prop updated.
This commit is contained in:
commit
8cc6726e2c
2 changed files with 17 additions and 1 deletions
|
@ -1,5 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
|
<Button @click="testUpdate()">Update Test</Button>
|
||||||
|
<br>
|
||||||
<Time :time="time1" />
|
<Time :time="time1" />
|
||||||
<br>
|
<br>
|
||||||
<Time :time="time2" />
|
<Time :time="time2" />
|
||||||
|
@ -10,6 +12,8 @@
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
|
const baseTime = parseInt(Date.now() / 10000000) * 10000000
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
|
@ -18,6 +22,12 @@
|
||||||
time3: (new Date()).getTime() - 1 * 1000,
|
time3: (new Date()).getTime() - 1 * 1000,
|
||||||
time4: (new Date()).getTime() - 86400 * 60 * 1000,
|
time4: (new Date()).getTime() - 86400 * 60 * 1000,
|
||||||
};
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
methods: {
|
||||||
|
testUpdate() {
|
||||||
|
this.time1 = parseInt(baseTime + Math.random() * 10000000)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -49,6 +49,12 @@
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
watch: {
|
||||||
|
time () {
|
||||||
|
// https://segmentfault.com/q/1010000021110866
|
||||||
|
if (!isServer) this.setTime();
|
||||||
|
}
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
handleClick () {
|
handleClick () {
|
||||||
if (this.hash !== '') window.location.hash = this.hash;
|
if (this.hash !== '') window.location.hash = this.hash;
|
||||||
|
|
Loading…
Add table
Reference in a new issue