<template v-if="ok">
<h1>Title</h1>
<p>Paragraph 1</p>
<p>Paragraph 2</p>
</template>
<script>
data:{
ok:true
}
</script>
<div v-if="ok"> Now you see me </div> <div v-else> Now you don't </div>
<div> <p v-if="sc>=90">优秀</p> <p v-else-if="sc>=60">及格</p> <p v-else="sc<60">不及格</p> </div>
<div class="exp">
<template v-if="loginType === 'username'">
<label>Username</label>
<input placeholder="Enter your username">
</template>
<template v-else>
<label>Email</label>
<input placeholder="Enter your email address">
</template>
<input type="button" @click="btn" value="切换"/>
</div>
<script>
var exp=new Vue({
el:".exp",
data:{
loginType:"username"
},
methods:{
btn:function(){
if(this.loginType==="username"){
this.loginType="email"
}else{
this.loginType="username"
}
}
}
})
</script>
<template v-if="loginType === 'username'"> <label>Username</label> <input placeholder="Enter your username" key="username"> </template> <template v-else> <label>Email</label> <input placeholder="Enter your email address" key="email"> </template>
<h1 v-show="ok">Hello!</h1>
<script>
data:{
ok:false
}
</script>
<div style="display:none;"></div>
<div class="exp">
<ul>
<li v-for="item in items">{{item.text}}</li>
</ul>
</div>
<script>
data:{
items:[
{text:"eat"},
{text:"play"},
{text:"game"}
]
}
</script>
<div class="exp">
<ul>
<li>eat</li>
<li>play</li>
<li>game</li>
</ul>
</div>
<div class="exp">
<ul>
<li v-for="item,index in items">{{index}}-{{item.text}}</li>
</ul>
</div>
<script>
var exp=new Vue({
el:".exp",
data:{
items:[
{text:'eat'},
{text:'paly'},
{text:'game'}
]
}
})
</script>
<div class="exp">
<ul>
<li v-for="value in obj">{{value}}</li>
</ul>
</div>
<script>
var exp=new Vue({
el:".exp",
data:{
obj:{
firstname:"PureView",
lastname:"一个安静的美男子",
age:18
}
}
})
</script>
<li v-for="value,key,index in obj">{{index+1}}. {{key}}: {{value}}</li>
<div class="exp">
<ul>
<li v-for="item in items">{{item.text}}</li>
</ul>
</div>
<script>
var exp=new Vue({
el:".exp",
data:{
items:[
{text:"eat"},
{text:"play"},
{text:"game"}
]
}
})
exp.items.push({text:'watch TV'})
</script>
data:{
items:[
{text:"eat"},
{text:"play"},
{text:"game"},
{text:"gaming"},
{text:"wot"},
{text:"wows"},
{text:"wt"}
]
}
}
exp.items.slice(0,5)
// Vue.set Vue.set(exp.items, indexOfItem, newValue)
// Array.prototype.splice exp.items.splice(indexOfItem, 1, newValue)
exp.items.splice(newLength)
var exp=new Vue({
data:{
a:1
}
})
vm.b=2 //模板内无响应
Vue.set(object,key,value)
var exp=new Vue({
el:".exp",
data:{
obj:{
me:"pureview",
pet1:"dog",
pet2:"cat",
hobby:"games"
}
}
})
Vue.set(exp.obj,"todo","eating")
Vue.delete(exp.obj,"pet2")
<div class="exp">
<ul>
<li v-for="n in numbers">{{n}}</li>
</ul>
</div>
<script>
var exp=new Vue({
el:".exp",
data:{
num:[1,2,3,4,5,6,7,8,9,10]
},
computed:{
numbers:function(){
return this.num.filter(function(num){
return num%2===0
})
}
}
})
</script>
<div class="exp">
<ul>
<li v-for="n in even(num)">{{n}}</li>
</ul>
</div>
<script>
var exp=new Vue({
el:".exp",
data:{
num:[1,2,3,4,5,6,7,8,9,10]
},
methods:{
even:function(num){
return num.filter(function(num){
return num%2===0
})
}
}
})
</script>
<div>
<span v-for="n in 10">{{ n }} </span>
</div>
<ul>
<template v-for="item in items">
<li>{{ item.msg }}</li>
<li class="divider"></li>
</template>
</ul>
<li v-for="todo in todos" v-if="!todo.isComplete">
{{ todo }}
</li>
<ul v-if="todos.length">
<li v-for="todo in todos">
{{ todo }}
</li>
</ul>
<p v-else>No todos left!</p>
<my-component v-for="(item,index) in items" v-bind:key="index" :lie="item.text"l></my-component>
<script>
Vue.component('mycom', {
template: "<p>{{this.lie}}</p>",
props:["lie"]
})
var exp=new Vue({
el:".exp",
data:{
items:[
{text:'从前有座山'},
{text:'山上有座庙'},
{text:'庙里有个老和尚'},
{text:'正在玩王者荣耀'}
]
}
})
</script>
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有