gui-row.vue 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <template>
  2. <view
  3. :class="classesRuntime"
  4. :style="styleRuntime">
  5. <slot></slot>
  6. </view>
  7. </template>
  8. <script>
  9. export default{
  10. name : "gui-column",
  11. props:{
  12. wrap : {type:Boolean, default:false},
  13. mainAxisAlignment : {type:String, default:'flex-start'},
  14. crossAxisAlignment : {type:String, default:'flex-start'},
  15. customStyle : {type:String, default:''},
  16. customClasses : {type:Array, default:function(){return [];}}
  17. },
  18. data() {
  19. return {
  20. styleRuntime : '',
  21. classesRuntime : []
  22. }
  23. },
  24. methods:{
  25. makeStyle : function(){
  26. var styleRuntime = 'justify-content:'+this.mainAxisAlignment+'; ';
  27. styleRuntime += 'align-items:'+this.crossAxisAlignment+'; ';
  28. styleRuntime += this.customStyle;
  29. this.styleRuntime = styleRuntime;
  30. },
  31. makeClasses : function(){
  32. var classes = ['gui-flex', 'gui-rows'];
  33. if(this.wrap){
  34. classes.push('gui-wrap');
  35. }else{
  36. classes.push('gui-nowrap');
  37. }
  38. classes = classes.concat(this.customClasses);
  39. this.classesRuntime = classes;
  40. }
  41. },
  42. mounted:function(){
  43. this.makeStyle();
  44. this.makeClasses();
  45. },
  46. watch:{
  47. mainAxisAlignment : function(){this.makeStyle();},
  48. crossAxisAlignment : function(){this.makeStyle();},
  49. customStyle : function(){this.makeStyle();},
  50. customClasses : function(){this.makeClasses();},
  51. wrap : function(){this.makeClasses();}
  52. }
  53. }
  54. </script>
  55. <style scoped>
  56. </style>