tnblog
首页
视频
资源
登录

uni-app官方view例子

7158人阅读 2022/1/20 16:46 总访问:891293 评论:0 收藏:0 手机
分类: .net

代码:

  1. <template>    
  2. <view>    
  3. <page-head title="view"></page-head>    
  4. <view class="uni-padding-wrap uni-common-mt">    
  5. <view class="uni-hello-text">    
  6. Flex是Flexible Box的缩写,意为“弹性布局”,用来为盒状模型提供最大的灵活性。当设置display: flex后,继续给view等容器组件设置flex-direction:    
  7. row或column,就可以在该容器内按行或列排布子组件。uni-app推荐使用flex布局。因为flex布局有利于跨更多平台,尤其是采用原生渲染的平台。    
  8. </view>    
  9. <view class="uni-title uni-common-mt">    
  10. flex-direction: row    
  11. <text>\n横向布局</text>    
  12. </view>    
  13. <view class="uni-flex uni-row">    
  14. <view class="flex-item uni-bg-red">A</view>    
  15. <view class="flex-item uni-bg-green">B</view>    
  16. <view class="flex-item uni-bg-blue">C</view>    
  17. </view>    
  18. <view class="uni-title uni-common-mt">    
  19. flex-direction: column    
  20. <text>\n纵向布局</text>    
  21. </view>    
  22. <view class="uni-flex uni-column">    
  23. <view class="flex-item flex-item-V uni-bg-red">A</view>    
  24. <view class="flex-item flex-item-V uni-bg-green">B</view>    
  25. <view class="flex-item flex-item-V uni-bg-blue">C</view>    
  26. </view>    
  27. <view class="uni-title uni-common-mt">    
  28. 更多布局示例    
  29. <text>\nflex布局演示</text>    
  30. </view>    
  31. <view>    
  32. <view class="text">纵向布局-自动宽度</view>    
  33. <view class="text" style="width: 300rpx;">纵向布局-固定宽度</view>    
  34. <view class="uni-flex uni-row">    
  35. <view class="text">横向布局-自动宽度</view>    
  36. <view class="text">横向布局-自动宽度</view>    
  37. </view>    
  38. <view class="uni-flex uni-row" style="-webkit-justify-content: center;justify-content: center;">    
  39. <view class="text">横向布局-居中</view>    
  40. <view class="text">横向布局-居中</view>    
  41. </view>    
  42. <view class="uni-flex uni-row" style="-webkit-justify-content: flex-end;justify-content: flex-end;">    
  43. <view class="text">横向布局-居右</view>    
  44. <view class="text">横向布局-居右</view>    
  45. </view>    
  46. <view class="uni-flex uni-row">    
  47. <view class="text" style="-webkit-flex: 1;flex: 1;">横向布局-平均分布</view>    
  48. <view class="text" style="-webkit-flex: 1;flex: 1;">横向布局-平均分布</view>    
  49. </view>    
  50. <view class="uni-flex uni-row" style="-webkit-justify-content: space-between;justify-content: space-between;">    
  51. <view class="text">横向布局-两端对齐</view>    
  52. <view class="text">横向布局-两端对齐</view>    
  53. </view>    
  54. <view class="uni-flex uni-row">    
  55. <view class="text" style="width: 200rpx;">固定宽度</view>    
  56. <view class="text" style="-webkit-flex: 1;flex: 1;">自动占满余量</view>    
  57. </view>    
  58. <view class="uni-flex uni-row">    
  59. <view class="text" style="width: 200rpx;">固定宽度</view>    
  60. <view class="text" style="-webkit-flex: 1;flex: 1;">自动占满</view>    
  61. <view class="text" style="width: 200rpx;">固定宽度</view>    
  62. </view>    
  63. <view class="uni-flex uni-row" style="-webkit-flex-wrap: wrap;flex-wrap: wrap;">    
  64. <view class="text" style="width: 280rpx;">一行显示不全,wrap折行</view>    
  65. <view class="text" style="width: 280rpx;">一行显示不全,wrap折行</view>    
  66. <view class="text" style="width: 280rpx;">一行显示不全,wrap折行</view>    
  67. </view>    
  68. <view class="uni-flex uni-row">    
  69. <view class="text uni-flex" style="-webkit-flex: 1;flex: 1;height: 200rpx;-webkit-justify-content: center;justify-content: center;-webkit-align-items: flex-start;align-items: flex-start;">    
  70. <text>垂直居顶</text>    
  71. </view>    
  72. <view class="text uni-flex" style="-webkit-flex: 1;flex: 1;height: 200rpx;-webkit-justify-content: center;justify-content: center;-webkit-align-items: center;align-items: center;">    
  73. <text>垂直居中</text>    
  74. </view>    
  75. <view class="text uni-flex" style="-webkit-flex: 1;flex: 1;height: 200rpx;-webkit-justify-content: center;justify-content: center;-webkit-align-items: flex-end;align-items: flex-end;">    
  76. <text>垂直居底</text>    
  77. </view>    
  78. </view>    
  79. </view>    
  80. <view class="uni-title uni-common-mt">    
  81. 组合示例    
  82. <text>\nflex布局演示</text>    
  83. </view>    
  84. <view class="uni-flex uni-row">    
  85. <view class="text uni-flex" style="width: 200rpx;height: 220rpx;-webkit-justify-content: center;justify-content: center;-webkit-align-items: center;align-items: center;">    
  86. <image src="../../../static/plus.png" style="width: 150rpx;height: 150rpx;"></image>    
  87. </view>    
  88. <view class="uni-flex uni-column" style="-webkit-flex: 1;flex: 1;-webkit-justify-content: space-between;justify-content: space-between;">    
  89. <view class="text" style="height: 120rpx;text-align: left;padding-left: 20rpx;padding-top: 10rpx;">    
  90. 文字居左,留出左间距    
  91. </view>    
  92. <view class="uni-flex uni-row">    
  93. <view class="text" style="-webkit-flex: 1;flex: 1;">剩余数量</view>    
  94. <view class="text" style="-webkit-flex: 1;flex: 1;">立即购买</view>    
  95. </view>    
  96. </view>    
  97. </view>    
  98. </view>    
  99. </view>    
  100. </template>    
  101. <script>    
  102.  export default {    
  103.  data() {    
  104.  return {}    
  105.  }    
  106.  }    
  107. </script>    
  108. <style>    
  109.  .flex-item {    
  110.  width33.3%;    
  111.  height200rpx;    
  112.  text-align: center;    
  113.  line-height200rpx;    
  114.  }    
  115.  .flex-item-V {    
  116.  width100%;    
  117.  height150rpx;    
  118.  text-align: center;    
  119.  line-height150rpx;    
  120.  }    
  121.  .text {    
  122.  margin15rpx 10rpx;    
  123.  padding0 20rpx;    
  124.  background-color#ebebeb;    
  125.  height70rpx;    
  126.  line-height70rpx;    
  127.  text-align: center;    
  128.  color#777;    
  129.  font-size26rpx;    
  130.  }    
  131.  .desc {    
  132.  /* text-indent: 40rpx; */    
  133.  }    
  134.  .flex-pc {    
  135.  display: flex;    
  136.  justify-content: center;    
  137.  }    
  138. </style>


欢迎加群讨论技术,1群:677373950(满了,可以加,但通过不了),2群:656732739。有需要软件开发,或者学习软件技术的朋友可以和我联系~(Q:815170684)

评价

uni-app开始时间与结束时间(结束时间大于开始时间)picker编写

利用uni-app官网里面picker插件代码当点击开始时间后结束时间要大于选择后的开始时间,点击结束时间后开始时间要小于开始时...

uni-app用法与html标签的变化

以前是html标签,比如,现在是小程序组件,比如。那么标签和组件有什么区别,不都是用尖括号包围起来一段英文吗?其实标签...

uni-app无法导入插件

点击网页中右上角的插件导入,可以打开项目,但是就是无法导入插件。是因为,要登录!hbuilder里边也要登录才行,他这个应...

使用uni-app的云端一体插件

初次使用uni-app的云端一体插件步骤还是有点多,也有一些坑,在这里把使用过程记录一下。 一:先下载需要的插件在插件右上...

uni-app中list插件图标问题

如图:他使用uni-icons实现的如果只有text就不会有图标有时候贴的文档不是太完善,还是要下一个完整的插件来对比一下

uni-app发起请求

代码如下:uni.request({ url:&#39;接口地址&#39;, success:(result)=&gt;{ my.lists=result.data; } })注意你的...

uni-app官方文档

https://uniapp.dcloud.io/

uni-app运行与调试

上边有菜单,可以运行到浏览器,也可以运行到内置浏览器运行到内置浏览器的效果:

uni-app引入外部资源,引入外网样式

很简单代码如下:&lt;style&gt; @import&#39;http://image.tnblog.net/amazeui.min.css&#39;; &lt;/style&gt; &lt;st...

uni-app设置起始页

很简单,在pages.json里边配置即可。

uni-app页面无法跳转问题

首先检查一下有没有在pages里边配置没有配置不行的哦或者看看你的跳转方式对不对,如果跳转的是底部菜单,但是你用的是uni....

uni-app 删除失败 setting denied access to....

删除的时候如果文件夹下面还有页面,这样直接删除文件夹是会报错的:删除失败 setting denied access to....这种情况就直接...

uni-app中引入外部js

可以使用代码如下:varscript=document.createElement(&#39;script&#39;); script.src=&quot;http://image.tnblog.net/jqu...

uni-app dom操作

比如引入外部js需要用到的dom操作:varscript=document.createElement(&#39;script&#39;); script.src=&quot;http://image....

uni-app使用web-view引入页面

代码如下:&lt;template&gt; &lt;viewclass=&quot;h5-html&quot;&gt; &lt;web-view:webview-styles=&quot;webviewStyl...

uni-app真机调试

很简单只要手机开启了usb调试,然后hbuilderx会自动获取到手机的然后运行到手机即可华为手机开启use调试:一直点击版本号进...
这一生多幸运赶上过你.
排名
8
文章
243
粉丝
7
评论
7
ICP备案 :渝ICP备18016597号-1
网站信息:2018-2025TNBLOG.NET
技术交流:群号656732739
联系我们:contact@tnblog.net
公网安备:50010702506256
欢迎加群交流技术