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>

 

posted @ 2020-09-03 17:19  ♥之  阅读(169)  评论(0编辑  收藏  举报