uni-app样式的使用

<template>
    <view class="content f f-wrap">

       
        <!--
            前:样式
            后:控制:显示/隐藏
         -->


        <!-- 单类 -->
        <view :class="{ active: isActive }">111</view>

        <!-- 对象 -->
        <view class="static" :class="{ active: isActive, 'text-danger': hasError }">222</view>

        <!-- 数组 -->
        <view class="static" :class="[activeClass, errorClass]">333</view>

        <!-- 条件 -->
        <view class="static" v-bind:class="[isActive ? activeClass : '', errorClass]">444</view>

        <!-- 数组+对象 -->
        <view class="static" v-bind:class="[{ activeGrey: isActive }, errorClass]">555</view>

        <!-- 执行类 -->
        <view class="container" :class="computedClassStr"></view>
        <view class="container" :class="{activeGrey: isActive}">9999</view>

         

        <!-- style支持的类 -->
        <view v-bind:style="{ color: activeColor, fontSize: fontSize + 'px' }">666</view>
        <view v-bind:style="[{ color: activeColor, fontSize: fontSize + 'px' }]">777</view>
        
        
        <!-- 复杂样式的定义 -->
         
        <view > <text  :style="{'border-bottom':isShow?'2px  solid  '+bordline:''}"  style="display: inline-block; "  >玩传奇,赚大钱</text></view>
        
<view> <text  :class="isShow?'boxclass1':'boxclass2'"  style="display: inline-block;text-align: center;"  >租女友200一晚</text></view>
    </view>
</template>

<script>



    export default {
        data() {
            return {
                title: 'Hello',
                 isShow:true,
                 bordline:"red",
                // 单激活类
                isActive: true,
                hasError: true,

                // 多种激活类
                activeClass: {
                    'active': false,
                    'text-danger': true
                },
                errorClass: {
                    'active': true,
                    'text-danger': false
                },

                activeColor:true,
                fontSize:30
            }
        },
        onLoad() {
            this.fetchData()
            console.log('页面加载')
        },
        onShow() {
            console.log('页面显示')
        },
        onReady() {
            console.log('页面初次显示')
        },
        onHide() {
            console.log('页面隐藏')
        },
        onUnload() {
            console.log('页面卸载')
        },
        onBackPress() {
            console.log('页面返回...')
        },
        onShareAppMessage() {
            console.log('分享!')
        },
        onReachBottom() {
            console.log('下拉加载...')
        },
        onPageScroll() {
            console.log('页面滚动...')
        },
        onPullDownRefresh() {
            console.log('上拉刷新...')
            uni.stopPullDownRefresh();
        },

        // #ifdef APP-PLUS
        onNavigationBarButtonTap() {

        },
        // #endif

        methods: {
            tap(e) {
                console.log('tap点击!', e);
            },
            fetchData() {
                console.log('拉取数据...');
            },
            computedClassStr() {
                return this.isActive ? 'actives' : 'active'
            }
        }
    }
</script>

<style lang="scss">
    .active {
        color: #f00;
    }

    .activeGrey {
        color: #aaa;
    }

    .text-danger {
        color: #f0f;
        font-weight: bold;
    }

    .f {
       
    }

    .f-wrap {
        flex-wrap: wrap;
    }
    .boxclass1{
      width: 200px;
      height: 200px;
      background-color: #007AFF;
       
    }
    .boxclass2{
      width: 200px;
      height: 200px;
      background-color: #325343;
    }
</style>

效果:

在这里插入图片描述
在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
uni-app使用uni-list,你可以按照以下步骤进行操作: 1. 在页面中引入uni-list组件,可以通过在页面的json文件中添加"usingComponents"字段来引入组件,或者直接在页面的vue文件中使用import语句引入组件。 2. 在页面的template中使用uni-list组件,可以通过在template中添加<uni-list>标签来创建一个列表。 3. 在<uni-list>标签内部,可以使用<uni-list-item>标签来创建列表项。你可以使用v-for指令来循环渲染多个列表项,可以参考\[3\]中的示例。 4. 可以通过在<uni-list-item>标签上设置样式来自定义列表项的外观。根据\[3\]中的描述,如果要设置<uni-list-item>的样式,需要在它外层的view标签上设置才会生效。 总结起来,使用uni-list在uni-app中创建列表的步骤是:引入组件、创建<uni-list>标签、在<uni-list>标签内部使用<uni-list-item>标签循环渲染列表项,并在view标签上设置样式。 #### 引用[.reference_title] - *1* *2* [【uni-app教程】uni-app入门教程](https://blog.csdn.net/beiluoL/article/details/129264321)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] - *3* [uni-appuni-list列表分割线不显示问题](https://blog.csdn.net/weixin_57375608/article/details/129951060)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

你的美,让我痴迷

你的好,我会永远记住你的。

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值