close
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="http://cdnjs.cloudflare.com/ajax/libs/vue/1.0.26/vue.min.js"></script>
</head>
<body>
<div id="app">
<button v-on:click='toggleView'>登入或登出</button>
<div v-if="login">你登入囉</div>
<div v-if='!login'>你登出囉</div>
</div>
<script type="text/javascript">
var vm = new Vue({
el: "#app",
data:{
login:false
},
methods:{
toggleView:function(value){
this.login ^= true;
}
}
})
</script>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="http://cdnjs.cloudflare.com/ajax/libs/vue/1.0.26/vue.min.js"></script>
</head>
<body>
<div id="app">
<h2>{{message}}</h2>
<button @click='toggleView'>登入或登出</button>
<div v-if="login">你登入囉</div>
<div v-if='!login'>你登出囉</div>
</div>
<script type="text/javascript">
var vm = new Vue({
el: "#app",
data:{
login:false,
message:'還沒點'
},
methods:{
toggleView:function(value){
this.login ^= true;
this.message=value.type;
console.log(value);
// 打開console會發現有非多屬性可以用
}
}
})
</script>
</body>
</html>
全站熱搜
留言列表