VUX version
2.9.2
OS/Browsers version
mui8/vue的app
Vue version
2.5.17-beta.0
Code
<template>
<datetime v-model="time" :placeholder="'选择'" format="YYYY-MM-DD"></datetime>
<span @click="fn"></span>
</template>
<script>
export default {
name: 'school',
data () {
return {
time :''
}
},
methods:{
fn(){
this.time = '2017-10-10'
}
},
mounted(){
this.time = '2017-10-10'
}
}
</script>
Steps to reproduce
在mounted里面初始化time的值datetime的文本框值没变化,但是点击事件fn却能够改变datetime的文本框值,mounted不可以?这是怎么回事?
What is Expected?
解决mounted初始化值的问题
What is actually happening?
无
1条答案
按热度按时间lc8prwob1#
mounted() {
this.$nextTick(()=>{
this.time= '2017-10-10'
})
}
nextTick加上就可以了 应该是要等dom渲染完