SOURCE

console 命令行工具 X clear

                    
>
console
var wearArr = ['T恤短裤','夹克长裙','棉衣羽绒服'];
var app = new Vue({
    el:'#app',
    data:{
        c:14,
        wear:"夹克长裙"
    },
    methods:{
        up:function(){
            return this.c+=5;
        },
        down:function(){
            return this.c-=5;
        }
    },
    // watch:{
    //     c:function(newVal,oldVal){
    //         if(newVal>=26){
    //             this.wear = wearArr[0];
    //         }else if(newVal<26 && newVal>0){
    //             this.wear = wearArr[1];
    //         }else{
    //             this.wear = wearArr[2];
    //         }
    //     }
    // }
});
app.$watch("c",function(newVal,oldVal){
    if(newVal>=26){
                this.wear = wearArr[0];
            }else if(newVal<26 && newVal>0){
                this.wear = wearArr[1];
            }else{
                this.wear = wearArr[2];
            }
})
<script src="https://unpkg.com/vue"></script>
<h1>Methods Option</h1>
<hr />
<div id="app">
    <p>今天温度:<span v-text="c"></span>°</p>
    <p>建议穿:<span v-text="wear"></span></p>
    <p>
        <button @click="up">升高温度</button>
        <button @click="down">降低温度</button>
    </p>
</div>
*:not(button){
    color:#fff;
}
a:visited{
    color:lightblue
}