当前位置: 首页 > news >正文

小程序uniapp元素动态样式的写法

1. 在css中使用data里的变量

<template><view class="center" :style="{'--windowWidth':windowWidth}"></view>
</template><script>const windowWidth = uni.getSystemInfoSync().windowWidth+'px';
</script><style>border-right: var(--window-width) solid transparent;//注意--window-width的写法,可以html里查看写法
</style>

2. 在元素中使用:style

1. 
:style="{'left':item.left+'rpx;','bottom':item.bottom+'rpx'}"2.
:style="{ height: (isOpen ? height : 0) + 'px' }"3. 
:style="{width:drawerWidth+'px'}"4.
:style="'width:'+width+';'+(square?'height:'+width:'')"5.
:style="{backgroundColor:index<=active&&index!==0?activeColor:index===0?'transparent':deactiveColor}"


http://www.mrgr.cn/news/30378.html

相关文章:

  • 如何使用 Next.js 进行服务端渲染(Server-Side Rendering, SSR)
  • 兔子检测系统源码分享
  • 代码随想录 | Day22 | 二叉树:二叉搜索树中的搜索验证二叉搜索树
  • JavaScript在数据可视化领域的探索与实践
  • 云上办公项目总结
  • 【树莓派】利用socket改善树莓派3B运行YOLO运力不够
  • 宠物空气净化器真的有必要买吗?哪款真的能吸毛?
  • C++中string类的使用
  • HarmonyOS开发实战(5.0)实现二楼上划进入首页效果详解
  • Haproxy搭建Web集群
  • Python 中的异步编程:从入门到实践
  • 打破转化阻碍:Xinstall实现全渠道一键拉起
  • C++ —— 关于vector
  • vue2.0+ts注册全局函数和几个递归查找
  • vue h5 蓝牙连接 webBluetooth API
  • 对 JavaScript 原型的理解
  • ELK企业级日志分析系统
  • 从工厂打螺丝到数据库专家(上)
  • 把设计模式用起来!(4) 用不好模式?之原理不明
  • FortiGate 透明模式下配置注意事项和故障排错技巧