找回密码
 立即注册
搜索

select组件更新数据提示removeView(View) is not supported in AdapterView

3
回复
2174
查看
[复制链接]

2

主题

7

帖子

45

积分

 楼主| 2018-5-3 22:38:13 显示全部楼层 |阅读模式
想使用select做一个省市区三级联动,可是为什么更新市区数据时老是提示removeView(View) is not supported in AdapterView?
  1. <template>
  2. <div style="width: 100%;height: 80px;">
  3. <select class="_city-select" onchange="onChange(1)">
  4. <option class="_city-option" for="province" selected="{{$idx==defaultCity[0]}}" value="{{$idx}}">{{$item.province}}</option>
  5. </select>
  6. <select class="_city-select" onchange="onChange(2)">
  7. <option class="_city-option" for="city" selected="{{$idx==defaultCity[1]}}" value="{{$idx}}">{{$item.city}}</option>
  8. </select>
  9. <select class="_city-select" onchange="onChange(3)">
  10. <option class="_city-option" for="district" selected="{{$idx==defaultCity[2]}}" value="{{$idx}}">{{$item.district}}</option>
  11. </select>
  12. </div>
  13. </template>
复制代码
从log上看市区的数据已经正常改变了,格式也是正确的。
  1. [{"city":"北京","district":[{"district":"北京"},{"district":"海淀"},{"district":"朝阳"},{"district":"顺义"},{"district":"怀柔"},{"district":"通州"},{"district":"昌平"},{"district":"延庆"},{"district":"丰台"},{"district":"石景山"},{"district":"大兴"},{"district":"房山"},{"district":"密云"},{"district":"门头沟"},{"district":"平谷"}]}]
  2. [{"district":"北京"},{"district":"海淀"},{"district":"朝阳"},{"district":"顺义"},{"district":"怀柔"},{"district":"通州"},{"district":"昌平"},{"district":"延庆"},{"district":"丰台"},{"district":"石景山"},{"district":"大兴"},{"district":"房山"},{"district":"密云"},{"district":"门头沟"},{"district":"平谷"}]
  3. 0,0,0
  4. [{"city":"北京","district":[{"district":"北京"},{"district":"海淀"},{"district":"朝阳"},{"district":"顺义"},{"district":"怀柔"},{"district":"通州"},{"district":"昌平"},{"district":"延庆"},{"district":"丰台"},{"district":"石景山"},{"district":"大兴"},{"district":"房山"},{"district":"密云"},{"district":"门头沟"},{"district":"平谷"}]}]
  5. [{"district":"北京"},{"district":"海淀"},{"district":"朝阳"},{"district":"顺义"},{"district":"怀柔"},{"district":"通州"},{"district":"昌平"},{"district":"延庆"},{"district":"丰台"},{"district":"石景山"},{"district":"大兴"},{"district":"房山"},{"district":"密云"},{"district":"门头沟"},{"district":"平谷"}]
  6. 0,0,0
  7. [{"city":"北京","district":[{"district":"北京"},{"district":"海淀"},{"district":"朝阳"},{"district":"顺义"},{"district":"怀柔"},{"district":"通州"},{"district":"昌平"},{"district":"延庆"},{"district":"丰台"},{"district":"石景山"},{"district":"大兴"},{"district":"房山"},{"district":"密云"},{"district":"门头沟"},{"district":"平谷"}]}]
  8. [{"district":"北京"},{"district":"海淀"},{"district":"朝阳"},{"district":"顺义"},{"district":"怀柔"},{"district":"通州"},{"district":"昌平"},{"district":"延庆"},{"district":"丰台"},{"district":"石景山"},{"district":"大兴"},{"district":"房山"},{"district":"密云"},{"district":"门头沟"},{"district":"平谷"}]
  9. 0,0,0
  10. [{"city":"上海","district":[{"district":"上海"},{"district":"闵行"},{"district":"宝山"},{"district":"嘉定"},{"district":"浦东南汇"},{"district":"金山"},{"district":"青浦"},{"district":"松江"},{"district":"奉贤"},{"district":"崇明"},{"district":"徐家汇"},{"district":"浦东"}]}]
  11. [{"district":"上海"},{"district":"闵行"},{"district":"宝山"},{"district":"嘉定"},{"district":"浦东南汇"},{"district":"金山"},{"district":"青浦"},{"district":"松江"},{"district":"奉贤"},{"district":"崇明"},{"district":"徐家汇"},{"district":"浦东"}]
  12. 1,0,0
复制代码
可是还是报不能remove的错误!!字面上的理解是不支持removeView,可是不改变原来的数据怎么实现三级联动???希望有知道原因的人能告诉我一下,谢谢了!或者有其他实现的方法也麻烦告诉我一下!
回复

使用道具 举报

2

主题

7

帖子

45

积分

 楼主| 2018-5-3 22:43:12 显示全部楼层
上面少传了一些代码,补一下
  1. <style>
  2. ._city-select{
  3. flex-grow: 1;
  4. justify-content: center;
  5. font-size: 42px;
  6. padding: 15px;
  7. }
  8. ._city-option{
  9. justify-content: center;
  10. font-size: 38px;
  11. padding: 10px;
  12. }
  13. </style>
  14. <script>
  15. import citys from '../../Server/cityData';
  16. import strings from '../../Server/strings';
  17. import Prompt from '@system.prompt';
  18. export default {
  19. data:{
  20. defaultCity:strings.defaultCity,
  21. province:citys.cityList,
  22. city:[],
  23. district:[]
  24. },
  25. onChange(type,e){
  26. this.city = this.province[parseInt(e.newValue)].city;
  27. this.district=this.city[0].district;
  28. console.log(JSON.stringify(this.city));
  29. console.log(JSON.stringify(this.district));
  30. this.defaultCity = [parseInt(e.newValue),0,0];
  31. console.log(this.defaultCity);
  32. //this.changeData(0);
  33. }
  34. }
  35. </script>
复制代码
回复

使用道具 举报

2

主题

15

帖子

80

积分

2018-5-31 10:14:04 显示全部楼层
兄弟,你咋弄得
回复

使用道具 举报

1

主题

15

帖子

80

积分

2019-6-2 11:27:02 显示全部楼层
你好,建议参考这个demo的写法 https://github.com/l455202325/APIDemo
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册