vue中Select下拉框用v-model绑定了一个值,用v-for遍历出来多个,改变一个下拉框的选项,其他的都会改变将途中这个遍历出来多个,改变其中一个的值, vue中Select下拉框用v-model绑定了一个值,用v-for遍历出来多个,改变一个下拉框的选项,其他的都会改变将途中这个遍历出来多个,改变其中一个的值,其他都会变,我应该怎样解决??不让他们联动 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 不要绑定同一个v-model @summer_雪 就是 现在循环出来的数据下拉框选择其中一个 其他的数据的下拉框也跟着改变成同样的值, 因为他们的v-model绑定是同一条数据(循环出来的数据v-mdel不能改变)。现在就是想让它单独来选 其他的不受影响 <!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title></head><body> <div id="app"> <select v-model="selectedA"> <option v-for="option in options" v-bind:value="option.value">{{ option.text }} </option> </select> <span>SelectedA: {{ selectedA }}</span> <hr /> <select v-model="selectedB"> <option v-for="option in options" v-bind:value="option.value">{{ option.text }} </option> </select> <span>SelectedB: {{ selectedB }}</span> <hr /> <select v-model="selectedC"> <option v-for="option in options" v-bind:value="option.value">{{ option.text }} </option> </select> <span>SelectedC: {{ selectedC }}</span> <hr /> </div></body></html><script src="../../Scripts/VUE/vue.js"></script><script> new Vue({ el: '#app', data: { selectedA: 'A', selectedB: 'B', selectedC: 'C', options: [ { text: 'One', value: 'A' }, { text: 'Two', value: 'B' }, { text: 'Three', value: 'C' } ] } })</script> 我的是循环出来的数据 v-model只能绑定同一数据。 你现在是有多个select下拉选择框吗?每个都是循环的? 1.修改源数据,添加一个selectVal 属性,并把下拉菜单的第一个赋值到这里this.goodsList.forEach((item,index)=>{ item.checkd = false item.index = index item.selectVal = item.attr_name[0] })2.在视图层使用刚手动添加的属性,获取属性值<span>{{item.selectVal}}</span>3.在下来选择框中更改源数据中新增加的selectVal的属性值selectTypeHandle(item,e,index) { item.selectVal = e.currentTarget.dataset.value; }, 做web开发的朋友可以进来看看 请教js实现的功能 谢谢 jsp中如何获取网页载入的时间与提交的时间并求出两者之差返回给action? 继续JS控制表单提交的问题 求js 网页全屏代码 如何确保弹出窗口不被阻止 一个有关jQuery事件的疑问 gridpanel 带分页的查询 如何移动文本块的位置的问题 在输入框填充之后,再点击输入框,仍然没有触发.blur()和.focus()事件,比较疑惑 bootstrap-table的formatter中使用ajax的问题 JAVA web项目求助
就是 现在循环出来的数据下拉框选择其中一个 其他的数据的下拉框也跟着改变成同样的值, 因为他们的v-model绑定是同一条数据(循环出来的数据v-mdel不能改变)。现在就是想让它单独来选 其他的不受影响
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
</head>
<body>
<div id="app">
<select v-model="selectedA">
<option v-for="option in options" v-bind:value="option.value">{{ option.text }}
</option>
</select>
<span>SelectedA: {{ selectedA }}</span>
<hr />
<select v-model="selectedB">
<option v-for="option in options" v-bind:value="option.value">{{ option.text }}
</option>
</select>
<span>SelectedB: {{ selectedB }}</span>
<hr />
<select v-model="selectedC">
<option v-for="option in options" v-bind:value="option.value">{{ option.text }}
</option>
</select>
<span>SelectedC: {{ selectedC }}</span>
<hr />
</div>
</body>
</html>
<script src="../../Scripts/VUE/vue.js"></script>
<script>
new Vue({
el: '#app',
data: {
selectedA: 'A',
selectedB: 'B',
selectedC: 'C',
options: [
{ text: 'One', value: 'A' },
{ text: 'Two', value: 'B' },
{ text: 'Three', value: 'C' }
]
}
})
</script>
this.goodsList.forEach((item,index)=>{
item.checkd = false
item.index = index
item.selectVal = item.attr_name[0]
})2.在视图层使用刚手动添加的属性,获取属性值
<span>{{item.selectVal}}</span>3.在下来选择框中更改源数据中新增加的selectVal的属性值
selectTypeHandle(item,e,index) {
item.selectVal = e.currentTarget.dataset.value;
},