Type
当前位置:   article > 正文

HarmonyOS应用开发-qrcode二维码生成_qrcodetype

qrcodetype


一.创建项目
二.示例代码

Hml代码:

  1. <div class="container">
  2. <text class="txt">Type</text>
  3. <switch showtext="true" checked="true" texton="rect" textoff="circle" onchange="setType"></switch>
  4. <qrcode value="{{qr_value}}" type="{{qr_type}}"
  5. style="color: {{qr_col}};background-color: {{qr_bcol}};width: {{qr_size}};height: {{qr_size}};margin-bottom: 70px;">
  6. </qrcode>
  7. <text class="txt">Color</text>
  8. <select onchange="setColor">
  9. <option for="{{col_list}}" value="{{$item}}">{{$item}}</option>
  10. </select>
  11. <text class="txt">Background Color</text>
  12. <select onchange="setColorB">
  13. <option for="{{bcol_list}}" value="{{$item}}">{{$item}}</option>
  14. </select>
  15. </div>

 Css代码:

  1. .container {
  2. flex-direction: column;
  3. justify-content: center;
  4. align-items: center;
  5. }
  6. .txt {
  7. color: orangered;
  8. }

Js代码:

  1. export default {
  2. data: {
  3. qr_value:"这里是扫出的二维码内容",
  4. qr_type: 'rect',
  5. qr_size: '200px',
  6. qr_col: '#333',
  7. col_list: ['#87ceeb','#fa8072','#da70d6','#80ff00ff','#00ff00ff'],
  8. qr_bcol: '#f0ffff',
  9. bcol_list: ['#f0ffff','#ffffef','#d8bfd8']
  10. },
  11. setType(e) {
  12. if (e.checked) {
  13. this.qr_type = 'rect'
  14. } else {
  15. this.qr_type = 'circle'
  16. }
  17. },
  18. setColor(e) {
  19. this.qr_col = e.newValue
  20. },
  21. setColorB(e) {
  22. this.qr_bcol = e.newValue
  23. }
  24. }
  • 实例效果

 

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