drawerlayout

抽屉组件,会把内部的第一二个子元素作为侧边栏和主页,多出的元素不会加载

属性 作用
isOpen 控制打开关闭
方法 作用
toggel() 打开或关闭

事件

名称 触发时机
load 子元素加载完毕触发(注意:必须写在第一级子元素上)

Demo

  1. <template>
  2. <div style="justify-content: center;align-items: center">
  3. <div @click="setOpen" style="width: 100;height: 100;background-color: red">
  4. <text>打开</text>
  5. </div>
  6. <div @click="setClose" style="width: 100;height: 100;background-color: red">
  7. <text>关闭</text>
  8. </div>
  9. <drawerlayout
  10. style="width: 700;height: 800;background-color: chartreuse"
  11. :isOpen="open"
  12. :leftWidth="500"
  13. >
  14. <div @load="load" style="position: absolute;left: 0;top: 0;right: 0;bottom: 0;background-color: red;width: 500">
  15. <div style="flex: 1;background-color: #0085ee;justify-content: center;align-items: center">
  16. <text>侧边栏</text>
  17. <text>目前必须用2层div包裹才能保证填充满</text>
  18. <text>第一层的样式必须是position: absolute;left: 0;top: 0;right: 0;bottom: 0;</text>
  19. <text>第二层的样式必须是flex:1</text>
  20. <text>第一层div的宽度必须和leftWidth一致</text>
  21. </div>
  22. </div>
  23. <div style="position: absolute;left: 0;top: 0;right: 0;bottom: 0;background-color: red">
  24. <div style="flex: 1;background-color: #0085ee;justify-content: center;align-items: center">
  25. <text>主界面</text>
  26. <text>目前必须用2层div包裹才能保证填充满</text>
  27. <text>第一层的样式必须是position: absolute;left: 0;top: 0;right: 0;bottom: 0;</text>
  28. <text>第二层的样式必须是flex:1</text>
  29. </div>
  30. </div>
  31. </drawerlayout>
  32. </div>
  33. </template>
  34. <style>
  35. .cl {
  36. align-items: center;
  37. }
  38. </style>
  39. <style src="./style.css"></style>
  40. <script>
  41. export default {
  42. components: {},
  43. data () {
  44. return {
  45. back: "",
  46. header: {},
  47. open: false
  48. }
  49. },
  50. methods: {
  51. setOpen()
  52. {
  53. this.open=true;
  54. },
  55. setClose()
  56. {
  57. this.open=false;
  58. },
  59. post()
  60. {
  61. var self = this;
  62. self.back = "";
  63. const net = weex.requireModule('net');
  64. net.post('http://121.40.81.1:9080/edu/getBanners.do', {a: "1", b: "2"}, {}, function () {
  65. //start
  66. }, function (e) {
  67. //success
  68. self.back = e.res;
  69. self.header = r.headers;
  70. }, function (e) {
  71. //exception
  72. }, function () {
  73. //compelete
  74. });
  75. },
  76. get()
  77. {
  78. var self = this;
  79. const net = weex.requireModule('net');
  80. self.back = "";
  81. net.get('http://121.40.81.1:9080/edu/getBanners.do', {}, {}, function () {
  82. //start
  83. }, function (e) {
  84. //success
  85. self.back = e.res;
  86. }, function (e) {
  87. //exception
  88. }, function () {
  89. //compelete
  90. });
  91. }
  92. },
  93. created: function () {
  94. }
  95. }
  96. </script>