Vue0-生命周期-03

生命周期

生命周期指定就是一个对象从创建到销毁的整个过程。

Vue也是有的

完整的Vue周期包含8个阶段。

Vue官方生命周期流程图:

那这有什么用呢?我们可以在指定阶段做特殊的事件。

这些方法伴随生命周期的进行自动执行。

html 复制代码
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>通过Vue完成表格数据的渲染展示</title>
    <script src="js/vue.js"></script>
</head>
<body>
    <div id="app">
        
        <table border="1" cellspacing="0" width="60%">
            <tr>
                <th>编号</th>
                <th>姓名</th>
                <th>年龄</th>
                <th>性别</th>
                <th>成绩</th>
                <th>等级</th>
            </tr>

            <tr align="center" v-for="(user,index) in users">
                <td>{{index+1}}</td>
                <td>{{user.name}}</td>
                <td>{{user.age}}</td>
                <td >
                    <span v-if="user.gender == 1">男</span>
                    <span v-else-if="user.gender==2">女</span>
                </td>
                <td>{{user.score}}</td>
                <td>
                    <span v-show="user.score >= 85">优秀</span>
                    <span v-show="user.score > 60 && user.score < 85">及格</span>
                    <span style="color: red;" v-show="user.score < 60">不及格</span>
                </td>
            </tr>
        </table>

    </div>
</body>
<script>
    new Vue({
        el:"#app",
        data:{
            users: [{
                name: "Tom",
                age: 20,
                gender: 1,
                score: 78
            },{
                name: "Rose",
                age: 18,
                gender: 2,
                score: 86
            },{
                name: "Jerry",
                age: 26,
                gender: 1,
                score: 90
            },{
                name: "Tony",
                age: 30,
                gender: 1,
                score: 52
            }]
        },
        methods:{
            
        },
        mounted(){
            alert("挂载完成");
        }
        
    })
</script>
</html>
相关推荐
顾北122 分钟前
Java接入阿里百炼大模型实战指南
java·ai
毕设源码-郭学长3 分钟前
【开题答辩全过程】以 高校水电表缴费系统的设计与实现为例,包含答辩的问题和答案
java
win x4 分钟前
网络通信协议 第一部
java·网络协议
sunfove10 分钟前
Python 自动化实战:从识图点击、模拟真人轨迹到封装 EXE 全流程教学
开发语言·python·自动化
傻啦嘿哟10 分钟前
Python网页自动化操作全攻略:从入门到实战
开发语言·python·自动化
筱歌儿23 分钟前
TinyMCE-----word表格图片进阶版
开发语言·javascript·word
黎雁·泠崖32 分钟前
Java面向对象:对象数组进阶实战
java·开发语言
sg_knight38 分钟前
工厂方法模式(Factory Method)
java·服务器·python·设计模式·工厂方法模式·工厂模式
%xiao Q1 小时前
GESP C++四级-216
java·开发语言·c++
西红市杰出青年1 小时前
Python异步----------信号量
开发语言·python