动态class写法

我就是我 2021-07-25 19:47 566阅读 0赞

两种动态class写法

  1. :class="`showAi?'animate__animated animate__bounce':''`"

或者

  1. :class="{cur:current==index}"//最简单写法
  2. <template>
  3. <view style="display: flex;justify-content: center;">
  4. <image
  5. :class="{'animate__animated animate__slideInDown':showAi}"
  6. src="../../static/uni.png"
  7. mode=""
  8. style="width: 100px;height: 100px;"></image>
  9. <button type="default" @click="beginAnimate"></button>
  10. </view>
  11. </template>
  12. <script>
  13. import "animate.css"
  14. export default {
  15. name: '',
  16. data () {
  17. return {
  18. showAi:false
  19. }
  20. },
  21. methods:{
  22. beginAnimate(){
  23. this.showAi=true
  24. }
  25. }
  26. }
  27. </script>
  28. <style lang="less" scoped>
  29. </style>

发表评论

表情:
评论列表 (有 0 条评论,566人围观)

还没有评论,来说两句吧...

相关阅读

    相关 uni动态class

    niapp中给动态数据添加动态class的时候 有固定的class和动态的class共存的时候 class是可以和 :class共存的  所以可以 <te...

    相关 vue 动态样式写法

    在Vue中,可以使用动态样式来根据组件的数据或计算属性来动态地设置元素的样式。Vue提供了多种方式来实现动态样式的写法,以下是几种常见的方法: 使用:style指令: 可以

    相关 vue动态绑定class

    Vue.js 允许您使用 v-bind 指令或简写的 : 来动态绑定 class 属性。这允许您基于某些条件为元素添加或删除类名,从而实现动态样式控制。以下是一些示例: 动态

    相关 Class动态加载

    Class.forName("类的全称") 不仅表示了类的类类型,还代表了动态加载类。 请区分编译、运行。 编译时刻加载类是静态加载类,运行时刻加载类是动态加载类。