当前位置:   article > 正文

Harmonyos 自定义下拉列表框(select)_harmonyos 下拉列表

harmonyos 下拉列表

自定义一个下拉列表框,当这个功能有效时,点击可弹出下拉框,选中某个选项后,在左边功能名称下面显示选项值,右边的箭头替换成自定义图标,例如手法功能;当功能无效时,置灰,如力度功能;

具体示例如下:

 代码如下:index.hml

  1. <!--手法无效时-->
  2. <div class="fun-grid-item" if="{{manualInvalid}}">
  3. <div class="grid-item-parent-vertical">
  4. <text class="fun-name" style="opacity: 0.38;">手法</text>
  5. <text class="fun-status" show="false">{{manualIndex}}</text>
  6. </div>
  7. <div class="onOffLine_status" style="flex: 2;">
  8. <image src="/common/img/operate_drier_offline.png" style="width: 50px; height: 50px; "></image>
  9. </div>
  10. </div>
  11. <!--手法有效时-->
  12. <div class="fun-grid-item" else>
  13. <select on:change="changeSelect" style="opacity: 0;width: 100%;" disabled="{{isOnLine=='true'?(!(onOffStatus=='true')):true}}">
  14. <option for="{{ manualModeArr }}" value="{{ $item.value }}"
  15. selected="{{manualMode==$item.value?true:false}}">{{$item.name}}</option>
  16. </select>
  17. <div class="manualMode-valid">
  18. <div class="grid-item-parent-vertical">
  19. <text class="fun-name" style="opacity: {{isOnLine=='true'?(onOffStatus=='true'?1:0.38):0.38}};">手法</text>
  20. <text if="{{onOffStatus=='true'}}" class="fun-status" show="{{isOnLine=='true'?manualMode!='0'?true:false:false}}">{{manualIndex}}</text>
  21. <text else class="fun-status" show="false">{{manualIndex}}</text>
  22. </div>
  23. <div class="onOffLine_status" style="flex:1;height: 50px;">
  24. <image show="{{onOffStatus=='true'}}" src="{{isOnLine=='true'?manualMode!='0'?'/common/img/operate_drier_sel.png':'/common/img/operate_drier_unsel.png':'/common/img/operate_drier_offline.png'}}" style="width: 50px; height: 50px; "></image>
  25. <image show="{{onOffStatus=='false'}}" src="/common/img/operate_drier_offline.png" style="width: 50px; height: 50px; "></image>
  26. </div>
  27. </div>
  28. </div>

index.css

  1. .manualMode-valid {
  2. text-align: center;
  3. align-items: center;
  4. display: flex;
  5. position: absolute;
  6. }
  7. .fun-grid-item {
  8. height: 138px;
  9. border-radius: 24px;
  10. background-color: #ffffff;
  11. text-align: center;
  12. align-items: center;
  13. width: 100%;
  14. }
  15. .grid-item-parent-vertical {
  16. display: flex;
  17. position: relative;
  18. flex-direction: column;
  19. align-items: center;
  20. justify-content: center;
  21. }
  22. .fun-name {
  23. font-family: HWtext-55ST;
  24. margin-left: 32px;
  25. font-size: 32px;
  26. text-align: center;
  27. }
  28. .fun-status {
  29. margin-left: 32px;
  30. font-size: 24px;
  31. color: #007DFF;
  32. margin-top: 6px;
  33. position: relative;
  34. font-family: HWtext-55ST;
  35. }
  36. .offLine_status {
  37. opacity: 0.38;
  38. }
  39. .onOffLine_status_label {
  40. text-align: center;
  41. margin-left: 32px;
  42. font-size: 36px;
  43. font-family: HWtext-65ST;
  44. color: #000000;
  45. }
  46. .onOffLine_status {
  47. display: flex;
  48. justify-content: flex-end;
  49. margin-right: 32px;
  50. }

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Cpp五条/article/detail/228851
推荐阅读
相关标签