我用View UI快速划分界面,这个Vue组件库有点强!

简介: 我用View UI快速划分界面,这个Vue组件库有点强!



View UI是基于Vue的一个组件库,能够帮助前端开发人员快速构建界面!

如果您还没有接触过View UI,还不会配置开发环境,请点击这里

先看一个花里胡哨的界面,感受一下吧!



 

 

一、基础用法

 

View UI 中含有 Grid 栅格 组件,我们可以使用它,对界面快速的划分。

如下图所示:

View UI 中含有 <Row> 标签,它就是我们所说的行 这一个概念

上图的每一行,都是由一对<Row>标签构成,代码如下:

1. <template>
2. <div>
3. <Row>
4. <Col span="12"><Button long type="warning">ZWZ-12</Button></Col>
5. <Col span="12"><Button long type="info">ZWZ-12</Button></Col>
6. </Row>
7. </div>
8. </template>

在<Row>标签内包含了<Col>标签,就是我们所说的列。View UI将界面按照横竖快速划分,先分行,再分列。

<Col>标签中,可以设置一个属性span,就是列的宽度

View UI将一整行平均分为24块,span属性就是当前<Col>占了几块。24是1,2,3,4,6,8,12,24的倍数,能够满足大多数的分割需求。

我这里使用加长版按钮铺满整合列,使得演示效果更加明显。

以上就是View UI中,横竖划分区域的基础用法。

 

二、间距分割

 

看了之前的界面,每个按钮之前紧密的安排在一起。但在实际应用中,明显是不行的。

列与列之前必须要有所空隙,这样才能让界面更具美感。比如下图所示:

View UI 当然考虑到了这一点,我们可以在<Row>标签中设置 gutter 属性,给列与列之前留出空隙

属性名 属性说明
gutter 栅格间距,单位 px,左右平分
1. <template>
2. <div>
3. <Row :gutter="16">
4. <Col span="8"><Button long type="primary">ZWZ-8</Button></Col>
5. <Col span="8"><Button long type="success">ZWZ-8</Button></Col>
6. <Col span="8"><Button long type="error">ZWZ-8</Button></Col>
7. </Row>
8. </div>
9. </template>

我们将<Row>标签的gutter属性设置为16,每个列之前的空隙就变成了16px,这样界面变得更加美观。

三、水平垂直居中

如果<Row>下的<Col>标签块数之和,不到24,就会出现空白的区域,如下所示:

这也是日常开发中经常遇到的问题,我们可以给<Row>标签设置align属性和justify属性,分别代表该行的垂直对齐方式和水平对齐方式

属性 属性说明 属性类型
align flex 布局下的垂直对齐方式,可选值为topmiddlebottom String
justify flex 布局下的水平排列方式,可选值为startendcenterspace-aroundspace-between String
1. <Row align="center" justify="center" :gutter="16">
2. </Row>

设置后,该行所在的列会被居中显示

 


本文首发CSDN,原文地址https://zwz99.blog.csdn.net/article/details/116882859


 

四、动态排序

 

之前横竖不管如何划分,都是固定死的。但是可曾想过,每个列需要动态定位。

比如四个列为1、2、3、4排列,某个事件后,需要1、3、2、4排列,这可咋整?

View UI作者当然也考虑到了这一点,我们只需要给<Col>标签设置order属性即可,order就是列所在行中的排序值,排序值越小越靠左。

属性名 属性说明
order 栅格的顺序,在flex布局模式下有效

我们给order设置一个自动变化定时器,就完成了下面的闪烁界面!

1. <template>
2. <div>
3. <Row :gutter="16">
4. <Col span="4" :order="index41"><Button long type="error">ZWZ-4</Button></Col>
5. <Col span="4" :order="index42"><Button long type="primary">ZWZ-4</Button></Col>
6. <Col span="4" :order="index43"><Button long type="info">ZWZ-4</Button></Col>
7. <Col span="4" :order="index44"><Button long type="success">ZWZ-4</Button></Col>
8. <Col span="4" :order="index45"><Button long type="warning">ZWZ-4</Button></Col>
9. <Col span="4" :order="index46"><Button long type="error">ZWZ-4</Button></Col>
10. </Row>
11. </div>
12. </template>

 


以上是我在实际开发中经常使用到的点,不知你有没有get到呢?

View UI还支持响应式布局,即根据浏览器宽度动态设置所在列的宽度,当然这在我的实际开发中很少用到,所以就不再一一叙述了。


完整代码:

1. <template>
2. <div>
3. <Row :gutter="16">
4. <Col span="12" :order="index11"><Button long type="primary">ZWZ-12</Button></Col>
5. <Col span="12" :order="index12"><Button long type="info">ZWZ-12</Button></Col>
6. </Row>
7. <br>
8. <Row :gutter="16">
9. <Col span="8" :order="index21"><Button long type="success">ZWZ-8</Button></Col>
10. <Col span="8" :order="index22"><Button long type="warning">ZWZ-8</Button></Col>
11. <Col span="8" :order="index23"><Button long type="error">ZWZ-8</Button></Col>
12. </Row>
13. <br>
14. <Row :gutter="16">
15. <Col span="6" :order="index31"><Button long type="primary">ZWZ-6</Button></Col>
16. <Col span="6" :order="index32"><Button long type="info">ZWZ-6</Button></Col>
17. <Col span="6" :order="index33"><Button long type="success">ZWZ-6</Button></Col>
18. <Col span="6" :order="index34"><Button long type="warning">ZWZ-6</Button></Col>
19. </Row>
20. <br>
21. <Row align="center" justify="center" :gutter="16">
22. <Col span="4" :order="index41"><Button long type="error">ZWZ-4</Button></Col>
23. <Col span="4" :order="index42"><Button long type="primary">ZWZ-4</Button></Col>
24. <Col span="4" :order="index43"><Button long type="info">ZWZ-4</Button></Col>
25. <Col span="4" :order="index44"><Button long type="success">ZWZ-4</Button></Col>
26. <Col span="4" :order="index45"><Button long type="warning">ZWZ-4</Button></Col>
27. <Col span="4" :order="index46"><Button long type="error">ZWZ-4</Button></Col>
28. </Row>
29. </div>
30. </template>
31. 
32. <script>
33. 
34. export default {
35. name: 'app',
36. data() {
37. return {
38. index11: 0,
39. index12: 1,
40. index21: 0,
41. index22: 1,
42. index23: 2,
43. index31: 0,
44. index32: 1,
45. index33: 2,
46. index34: 3,
47. index41: 0,
48. index42: 1,
49. index43: 2,
50. index44: 3,
51. index45: 4,
52. index46: 5,
53.     }
54.   },
55. methods: {
56. init() {
57. this.timer = setInterval(this.changeIndex, 100);
58.     },
59. changeIndex() {
60. this.index11 = (this.index11 + 1) % 2;
61. this.index12 = (this.index12 + 1) % 2;
62. this.index21 = (this.index21 + 1) % 3;
63. this.index22 = (this.index22 + 1) % 3;
64. this.index23 = (this.index23 + 1) % 3;
65. this.index31 = (this.index31 + 1) % 4;
66. this.index32 = (this.index32 + 1) % 4;
67. this.index33 = (this.index33 + 1) % 4;
68. this.index34 = (this.index34 + 1) % 4;
69. this.index41 = (this.index41 + 1) % 6;
70. this.index42 = (this.index42 + 1) % 6;
71. this.index43 = (this.index43 + 1) % 6;
72. this.index44 = (this.index44 + 1) % 6;
73. this.index45 = (this.index45 + 1) % 6;
74. this.index46 = (this.index46 + 1) % 6;
75.     }
76.   },
77. mounted() {
78. this.init();
79.   }
80. }
81. </script>
82. 
83. <style>
84. </style>

 


相关文章
|
2月前
|
JavaScript
Vue中如何实现兄弟组件之间的通信
在Vue中,兄弟组件可通过父组件中转、事件总线、Vuex/Pinia或provide/inject实现通信。小型项目推荐父组件中转或事件总线,大型项目建议使用Pinia等状态管理工具,确保数据流清晰可控,避免内存泄漏。
236 2
|
4月前
|
机器学习/深度学习 算法 定位技术
Baumer工业相机堡盟工业相机如何通过YoloV8深度学习模型实现裂缝的检测识别(C#代码UI界面版)
本项目基于YOLOv8模型与C#界面,结合Baumer工业相机,实现裂缝的高效检测识别。支持图像、视频及摄像头输入,具备高精度与实时性,适用于桥梁、路面、隧道等多种工业场景。
432 27
|
5月前
|
开发者 容器
44.[HarmonyOS NEXT RelativeContainer案例一] 掌握组件锚点布局:打造灵活精准的UI定位系统
在HarmonyOS NEXT的UI开发中,精确控制组件位置是构建复杂界面的关键。RelativeContainer作为一种强大的布局容器,通过锚点系统提供了精确定位能力,使开发者能够创建出灵活且精准的UI布局。本教程将详细讲解如何使用RelativeContainer的锚点布局功能,帮助你掌握这一核心技术。
168 4
|
5月前
|
设计模式 缓存 容器
06.HarmonyOS Next UI进阶:Text组件与视觉样式完全指南
在HarmonyOS Next应用开发中,Text组件是最基础也是最常用的UI元素之一。它不仅用于显示文本内容,还可以通过丰富的样式属性实现各种视觉效果。掌握Text组件的样式设置,是构建精美UI界面的基础技能。
240 1
|
5月前
|
人工智能 JavaScript 算法
Vue 中 key 属性的深入解析:改变 key 导致组件销毁与重建
Vue 中 key 属性的深入解析:改变 key 导致组件销毁与重建
663 0
|
7月前
|
JavaScript
vue实现任务周期cron表达式选择组件
vue实现任务周期cron表达式选择组件
909 4
|
5月前
|
JavaScript UED
用组件懒加载优化Vue应用性能
用组件懒加载优化Vue应用性能
|
2月前
|
Linux Go iOS开发
IDA 9.2 发布:Golang 改进、新 UI 组件、类型解析等
IDA Pro 9.2 (macOS, Linux, Windows) - 强大的反汇编程序、反编译器和多功能调试器
516 0
|
4月前
|
Web App开发 前端开发 JavaScript
Element UI框架中自定义input组件的placeholder样式。
确保这些样式在你的应用程序CSS文件中定义,且该文件已正确加载到项目中。通过以上方法,可以控制Element UI组件中input的placeholder样式,使其满足特定的设计要求。这些更改都是基于CSS伪元素进行的,因此并不会对DOM结构产生改变,保持了原有结构的简洁和高效。
386 12
|
5月前
|
移动开发 开发者
仓颉开发语言入门教程:常见UI组件介绍和一些问题踩坑
仓颉开发语言即将发布一周年,虽已有知名App应用,但教程稀缺且官网文档不够完善。幽蓝君推出系列教程,从零开始系统讲解移动开发。本期介绍常用UI组件:按钮、文本、图片、输入框与搜索框的使用方法及注意事项,帮助开发者快速上手仓颉语言。

热门文章

最新文章