vue,每次刷新加载都走mouted生命周期
父组件代码<template><div><div><h1>父级</h1><button @click="handleLoad">点击重新加载子级</button></div><ch...
·
父组件代码
<template>
<div>
<div>
<h1>父级</h1>
<button @click="handleLoad">点击重新加载子级</button>
</div>
<children :key="timer"></children>
</div>
</template>
<script>
import children from '@/components/parent/children'
export default {
name: 'parent',
components: { children },
data () {
return {
timer: ''
}
},
methods: {
handleLoad () {
this.timer = new Date().getTime()
}
}
}
</script>
子组件代码
<template>
<div>
子级
</div>
</template>
<script>
export default {
name: 'children',
data () {
return {}
},
created () {
console.log('重新加载啦')
}
}
</script>
更多推荐
已为社区贡献3条内容
所有评论(0)