uni-app-组件
uni-app组件生命周期与vue同
index
<template>
<view>
<login></login>
</view>
</template>
<script>
import login from '../../components/login/login.vue'
export default {
data() {
return {}
},
onLoad() {},
methods: {},
components: {
login
}
}
</script>
组件
<template>
<view>
<view>组件</view>
</view>
</template>
<script>
export default {
data() {
return {
intId: null
};
},
created() {
console.log("1")
this.intId = setInterval(() => {
console.log("执行定时器")
}, 1000)
},
destroyed() {
clearInterval(this.intId)
}
}
</script>
<style>
</style>

浙公网安备 33010602011771号