navbar.vue 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <template>
  2. <div>
  3. <nut-demoheader
  4. :name="$route.name"
  5. ></nut-demoheader>
  6. <!-- DEMO区域 -->
  7. <!-- DEMO代码 -->
  8. </div>
  9. </template>
  10. <script>
  11. export default {
  12. data(){
  13. return{
  14. direction: 'h',
  15. boundary: {top: 50, bottom: 20, left: 0, right: 0},
  16. isSide: false,
  17. demo1:`<nut-drag direction="h"></nut-drag>`,
  18. demo2:`<nut-drag :boundary="{top: 20, bottom: 20}"></nut-drag>`,
  19. demo3:`<nut-drag :isSide="false"></nut-drag>`,
  20. }
  21. },
  22. methods:{
  23. changeMove(x, e){
  24. let dom = e.currentTarget;
  25. let siblings = dom.parentElement.children;
  26. this.removeClass(siblings);
  27. dom.classList.add('curr');
  28. this.direction = x;
  29. },
  30. changeBoundary(x, e){
  31. let dom = e.currentTarget;
  32. let siblings = dom.parentElement.children;
  33. this.removeClass(siblings);
  34. dom.classList.add('curr');
  35. if (x=='y') {
  36. this.boundary = {top: 50, bottom: 20, left: 0, right: 0};
  37. }else{
  38. this.boundary = {top: 50, bottom: 0, left: 0, right: 0};
  39. }
  40. },
  41. changeSide(b, e){
  42. let dom = e.currentTarget;
  43. let siblings = dom.parentElement.children;
  44. this.removeClass(siblings);
  45. dom.classList.add('curr');
  46. dom.classList.add('curr');
  47. this.isSide = b;
  48. },
  49. removeClass(siblings){ //去除同级的class
  50. for ( let i in siblings) {
  51. if (siblings.hasOwnProperty(i) === true){
  52. siblings[i].className = 'button-primary';
  53. }
  54. }
  55. },
  56. }
  57. }
  58. </script>
  59. <style lang="scss" scoped>
  60. .button-primary{
  61. display: inline-block;
  62. height: 38px;
  63. padding: 0 10px;
  64. color: #555;
  65. text-align: center;
  66. font-size: 12px;
  67. line-height: 38px;
  68. text-decoration: none;
  69. white-space: nowrap;
  70. background-color: transparent;
  71. border-radius: 3px;
  72. border: 1px solid #bbb;
  73. cursor: pointer;
  74. box-sizing: border-box;
  75. &.curr{
  76. background-color: #33C3F0;
  77. border-color: #33C3F0;
  78. color: #fff;
  79. }
  80. }
  81. </style>