gpt4 book ai didi

vue.js - VueJS - 如何在单选按钮选择上显示不同的 div

转载 作者:搜寻专家 更新时间:2023-10-30 22:15:03 24 4
gpt4 key购买 nike

如何在单选按钮选择上显示不同的组件。

<input type="radio" name="book" value="One" checked="checked">
<input type="radio" name="book" value="Round">

<div> // this should show show default, One is selected
<p>Value One</p>
</div>
<div> // this should show show on radio change to Round selected
<p>Value Round</p>
</div>

最佳答案

这样的事情怎么样?

new Vue({
el: '#app',
data: {
x: 'one',
},
});
<script src="https://rawgit.com/vuejs/vue/dev/dist/vue.js"></script>

<div id="app">
<input type="radio" v-model="x" value="one">
<input type="radio" v-model="x" value="two">

<div v-show="x === 'one'">One</div>
<div v-show="x === 'two'">Two</div>
</div>

关于vue.js - VueJS - 如何在单选按钮选择上显示不同的 div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47844629/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com