`是构建布局必不可少的Temir组件。
322 | 这就像在浏览器中``。
323 |
324 | ```vue
325 |
328 |
329 |
330 |
331 | This is a box with margin
332 |
333 |
334 | ```
335 |
336 | #### 尺寸
337 |
338 | ##### width
339 |
340 | Type: `number` `string`
341 |
342 | 元素在空间中的宽度。
343 | 你还可以将其设置为百分比,它将根据父元素的宽度计算宽度。
344 |
345 | ```vue
346 |
347 |
348 | X
349 |
350 |
351 | //=> 'X '
352 |
353 | ```
354 |
355 | ```vue
356 |
357 |
358 |
359 | X
360 |
361 |
362 |
363 | Y
364 |
365 |
366 |
367 | //=> 'X Y'
368 |
369 | ```
370 |
371 | ##### height
372 |
373 | Type: `number` `string`
374 |
375 | 元素的行高。
376 | 你还可以将其设置为百分比,它将根据父元素的高度计算高度。
377 |
378 | ```vue
379 |
380 |
381 | X
382 |
383 | //=> 'X\n\n\n'
384 |
385 | ```
386 |
387 | ```vue
388 |
389 |
390 |
391 | X
392 |
393 |
394 |
395 | Y
396 |
397 |
398 | //=> 'X\n\n\nY\n\n'
399 |
400 | ```
401 |
402 | ##### minWidth
403 |
404 | Type: `number`
405 |
406 | 设置元素的最小宽度。
407 | 目前还不支持百分比,请参阅 https://github.com/facebook/yoga/issues/872。
408 |
409 | ##### minHeight
410 |
411 | Type: `number`
412 |
413 | 设置元素的最小高度。
414 | 目前还不支持百分比,请参阅 https://github.com/facebook/yoga/issues/872.
415 |
416 | #### Padding
417 |
418 | ##### paddingTop
419 |
420 | Type: `number`\
421 | Default: `0`
422 |
423 | 顶部内边距
424 |
425 | ##### paddingBottom
426 |
427 | Type: `number`\
428 | Default: `0`
429 |
430 | 底部内边距
431 |
432 | ##### paddingLeft
433 |
434 | Type: `number`\
435 | Default: `0`
436 |
437 | 左侧内边距
438 |
439 | ##### paddingRight
440 |
441 | Type: `number`\
442 | Default: `0`
443 |
444 | 右侧内边距
445 |
446 | ##### paddingX
447 |
448 | Type: `number`\
449 | Default: `0`
450 |
451 | 水平内边距。相当于设置`paddingLeft`和`paddingRight`。
452 |
453 | ##### paddingY
454 |
455 | Type: `number`\
456 | Default: `0`
457 |
458 | 垂直内边距。相当于设置`paddingTop` and `paddingBottom`。
459 |
460 | ##### padding
461 |
462 | Type: `number`\
463 | Default: `0`
464 |
465 | 所有的内边距。相当于设置 `paddingTop`,`paddingBottom`,`paddingLeft` and `paddingRight`。
466 |
467 | ```vue
468 |
469 |
470 | Top
471 |
472 |
473 |
474 | Bottom
475 |
476 |
477 |
478 | Left
479 |
480 |
481 |
482 | Right
483 |
484 |
485 |
486 | Left and right
487 |
488 |
489 |
490 | Top and bottom
491 |
492 |
493 |
494 | Top,bottom,left and right
495 |
496 |
497 |
498 | ```
499 |
500 | #### Margin
501 |
502 | ##### marginTop
503 |
504 | Type: `number`\
505 | Default: `0`
506 |
507 | 顶部外边距
508 |
509 | ##### marginBottom
510 |
511 | Type: `number`\
512 | Default: `0`
513 |
514 | 底部外边距
515 |
516 | ##### marginLeft
517 |
518 | Type: `number`\
519 | Default: `0`
520 |
521 | 左侧外边距
522 |
523 | ##### marginRight
524 |
525 | Type: `number`\
526 | Default: `0`
527 |
528 | 右侧外边距
529 |
530 | ##### marginX
531 |
532 | Type: `number`\
533 | Default: `0`
534 |
535 | 水平外边距。相当于设置 `marginLeft` and `marginRight`。
536 |
537 | ##### marginY
538 |
539 | Type: `number`\
540 | Default: `0`
541 |
542 | 垂直外边距。相当于设置 `marginTop` and `marginBottom`。
543 |
544 | ##### margin
545 |
546 | Type: `number`\
547 | Default: `0`
548 |
549 | 所有的外边距。相当于设置 `marginTop`, `marginBottom`, `marginLeft` and `marginRight`。
550 |
551 | ```vue
552 |
553 |
554 | Top
555 |
556 |
557 |
558 | Bottom
559 |
560 |
561 |
562 | Left
563 |
564 |
565 |
566 | Right
567 |
568 |
569 |
570 | Left and right
571 |
572 |
573 |
574 | Top and bottom
575 |
576 |
577 |
578 | Top, bottom, left and right
579 |
580 |
581 | ```
582 |
583 | #### Flex
584 |
585 | ##### flexGrow
586 |
587 | Type: `number`\
588 | Default: `0`
589 |
590 | 请查阅 [flex-grow](https://css-tricks.com/almanac/properties/f/flex-grow/).
591 |
592 | ```vue
593 |
594 |
595 | Label:
596 |
597 | Fills all remaining space
598 |
599 |
600 |
601 | ```
602 |
603 | ##### flexShrink
604 |
605 | Type: `number`\
606 | Default: `1`
607 |
608 | 请查阅 [flex-shrink](https://css-tricks.com/almanac/properties/f/flex-shrink/).
609 |
610 | ```vue
611 |
612 |
613 |
614 | Will be 1/4
615 |
616 |
617 |
618 | Will be 3/4
619 |
620 |
621 |
622 | ```
623 |
624 | ##### flexBasis
625 |
626 | Type: `number` `string`
627 |
628 | 请查阅 [flex-basis](https://css-tricks.com/almanac/properties/f/flex-basis/).
629 |
630 | ```vue
631 |
632 |
633 |
634 | X
635 |
636 |
637 |
638 | Y
639 |
640 |
641 | //=> 'X Y'
642 |
643 | ```
644 |
645 | ```vue
646 |
647 |
648 |
649 | X
650 |
651 |
652 |
653 | Y
654 |
655 |
656 | //=> 'X Y'
657 |
658 | ```
659 |
660 | ##### flexDirection
661 |
662 | Type: `string`\
663 | Allowed values: `row` `row-reverse` `column` `column-reverse`
664 |
665 | 请查阅 [flex-direction](https://css-tricks.com/almanac/properties/f/flex-direction/).
666 |
667 | ```vue
668 |
669 |
670 |
671 | X
672 |
673 |
674 |
675 | Y
676 |
677 |
678 | // X Y
679 |
680 |
681 | X
682 |
683 | Y
684 |
685 |
686 | // Y X
687 |
688 |
689 | X
690 | Y
691 |
692 | // X
693 | // Y
694 |
695 |
696 | X
697 | Y
698 |
699 | // Y
700 | // X
701 |
702 | ```
703 |
704 | ##### alignItems
705 |
706 | Type: `string`\
707 | Allowed values: `flex-start` `center` `flex-end`
708 |
709 | 请查阅 [align-items](https://css-tricks.com/almanac/properties/a/align-items/).
710 |
711 | ```vue
712 |
713 |
714 |
715 | X
716 |
717 |
718 |
719 | A
720 |
721 | B
722 |
723 | C
724 |
725 |
726 | // X A
727 | // B
728 | // C
729 |
730 |
731 |
732 | X
733 |
734 |
735 |
736 | A
737 |
738 | B
739 |
740 | C
741 |
742 |
743 | // A
744 | // X B
745 | // C
746 |
747 |
748 |
749 | X
750 |
751 |
752 |
753 | A
754 |
755 | B
756 |
757 | C
758 |
759 |
760 | // A
761 | // B
762 | // X C
763 |
764 | ```
765 |
766 | ##### alignSelf
767 |
768 | Type: `string`\
769 | Default: `auto`\
770 | Allowed values: `auto` `flex-start` `center` `flex-end`
771 |
772 | 请查阅 [align-self](https://css-tricks.com/almanac/properties/a/align-self/).
773 |
774 | ```vue
775 |
776 |
777 |
778 | X
779 |
780 |
781 | // X
782 | //
783 | //
784 |
785 |
786 |
787 | X
788 |
789 |
790 | //
791 | // X
792 | //
793 |
794 |
795 |
796 | X
797 |
798 |
799 | //
800 | //
801 | // X
802 |
803 | ```
804 |
805 | ##### justifyContent
806 |
807 | Type: `string`\
808 | Allowed values: `flex-start` `center` `flex-end` `space-between` `space-around`
809 |
810 | 请查阅 [justify-content](https://css-tricks.com/almanac/properties/j/justify-content/).
811 |
812 | ```vue
813 |
814 |
815 | X
816 |
817 | // [X ]
818 |
819 |
820 | X
821 |
822 | // [ X ]
823 |
824 |
825 | X
826 |
827 | // [ X]
828 |
829 |
830 | X
831 | Y
832 |
833 | // [X Y]
834 |
835 |
836 | X
837 | Y
838 |
839 | // [ X Y ]
840 |
841 | ```
842 |
843 | #### Visibility
844 |
845 | ##### display
846 |
847 | Type: `string`\
848 | Allowed values: `flex` `none`\
849 | Default: `flex`
850 |
851 | 设置此属性为`none`以隐藏该元素。
852 |
853 | #### Borders
854 |
855 | ##### borderStyle
856 |
857 | Type: `string`\
858 | Allowed values: `single` `double` `round` `bold` `singleDouble` `doubleSingle` `classic`
859 |
860 | 添加具有指定样式的边框,默认情况下不添加。
861 | Temir从[`cli-boxes`](https://github.com/sindresorhus/cli-boxes)模块中使用边框样式。
862 |
863 | ```vue
864 |
865 |
866 |
867 |
868 | single
869 |
870 |
871 |
872 | double
873 |
874 |
875 |
876 | round
877 |
878 |
879 |
880 | bold
881 |
882 |
883 |
884 |
885 |
886 | singleDouble
887 |
888 |
889 |
890 | doubleSingle
891 |
892 |
893 |
894 | classic
895 |
896 |
897 |
898 |
899 | ```
900 |
901 |
902 | ##### borderColor
903 |
904 | Type: `string`
905 |
906 | 改变边框颜色。
907 |
908 | 接受与``组件中的[`color`](#color)相同的值。
909 |
910 | ```vue
911 | ```vue
912 |
913 |
914 | Green Rounded Box
915 |
916 |
917 | ```
918 |
919 | ### ``
920 |
921 | 添加一个或多个换行符(`\n`)。
922 | 必须在``组件中使用。
923 |
924 | #### count
925 |
926 | Type: `number`\
927 | Default: `1`
928 |
929 | 要插入的换行数。
930 |
931 | ```vue
932 |
935 |
936 |
937 |
938 |
939 |
940 | Hello
941 |
942 |
943 |
944 | World
945 |
946 |
947 |
948 |
949 |
950 | ```
951 |
952 | Output:
953 |
954 | ```
955 | Hello
956 | World
957 | ```
958 |
959 | ### ``
960 |
961 | 沿其包含布局的主轴展开的灵活空间。
962 | 作为填充元素之间所有可用空间的快捷方式,它非常有用。
963 |
964 | 例如,在具有默认伸缩方向(`row`)的``中使用``将把"Left"定位到左边,并将"Right"推到右边。
965 |
966 | ```vue
967 |
970 |
971 |
972 |
973 | Left
974 |
975 | Right
976 |
977 |
978 |
979 | ```
980 |
981 | 在垂直伸缩方向(`column`),它会将"Top"定位到容器的顶部,并将"Bottom"推到它的底部。
982 | 注意,容器需要足够高才能看到效果。
983 |
984 | ```vue
985 |
988 |
989 |
990 |
991 | Top
992 |
993 | Bottom
994 |
995 |
996 |
997 | ```
998 |
999 | ## 致谢
1000 |
1001 | 这个项目的灵感来源于[ink](https://github.com/vadimdemedes/ink)
1002 |
1003 | [vite-node](https://github.com/antfu/vite-node)为实现HMR提供了强力的支持
1004 |
--------------------------------------------------------------------------------