<template>
<div id="Home" class="m-20">
<div v-if="showInput">
<input ref="input" />
</div>
</div>
</template>
<script>
export default {
name: 'Home',
components: {
Overview
},
props: {},
data() {
return {
showInput:false
}
},
computed: {},
created() {
},
mounted() {
this.showInput=true;
//vue真正渲染dom到页面之后才进行的操作
this.$nextTick(()=>{
this.$refs.input.focus()
})
},
watch: {},
methods: {},
destroyed() {
}
}
</script>
<style lang="scss">
</style>
nextTick——vue真正渲染dom到页面之后,进行操作
于 2019-09-02 16:01:48 首次发布