V-show的正确使用方法
1.v-show指令的作用是:根据切换元素的显示状态2.原理是修改元素 的display,实现显示隐藏3.通过判断自定义值为true或false进行隐藏显示下列是v-show最基本的引用方式<template><view class="" ><image src="../../static/c1.png"@click="cj()"></image>&
·
1.v-show指令的作用是:根据切换元素的显示状态
2.原理是修改元素 的display,实现显示隐藏
3.通过判断自定义值为true或false进行隐藏显示
下列是v-show最基本的引用方式
<template>
<view class="" >
<image src="../../static/c1.png" @click="cj()"></image>
<input type="text" value="" placeholder="我打打打" v-show="ww" />
</view>
</view>
</template>
<script>
export default {
data() {
return {
ww:true
// www:true,
// www:true
}
},
methods: {
cj(){
this.ww=!this.ww
}
}
}
</script>
也可以直接在html中进行取反达到图片切换效果
<template>
<view class="" >
<image src="../../static/c1.png" @click="cj()" v-show="ww"></image>
<image src="../../static/c2.png" @click="cj()" v-show="!ww"></image>
</view>
</view>
</template>
<script>
export default {
data() {
return {
ww:true
// www:true,
// www:true
}
},
methods: {
cj(){
this.ww=!this.ww
}
}
}
</script>
更多推荐
已为社区贡献1条内容
所有评论(0)