block


包装容器

<block> 内置组件是一个包装容器,只接受控制属性,不会渲染在页面中

示例

  1. <template>
  2. <view class="container">
  3. <block c-if="{{show}}">
  4. <text>chameleon</text>
  5. </block>
  6. <block c-else>
  7. <text>block</text>
  8. </block>
  9. <button c-bind:onclick="clickHandle"></button>
  10. </view>
  11. </template>
  12. <script>
  13. class Block {
  14. data = {
  15. show: true
  16. }
  17. methods = {
  18. clickHandle() {
  19. this.show = !this.show;
  20. }
  21. }
  22. }
  23. export default new Block();
  24. </script>
  25. <style scoped>
  26. .container {
  27. align-items: center;
  28. }
  29. </style>
  30. <script cml-type="json">
  31. {
  32. "base": {}
  33. }
  34. </script>