马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>
<body>
<div id="root">
<h1>今天天气很{{info}}{{x}}</h1>
<button @click="change()">切换天气</button>
</div>
<script>
new Vue({
el:'#root',
data:{
isHot:true,
x:1,
},
//计算属性中的函数调用时不应该加().
computed: {
info(){
return this.isHot ?'炎日':'凉爽';
}
},
methods:{
change(){
this.isHot=!this.isHot;
this.x++;
}
}
})
</script>
</body>
</html>
|