1***@163.com
1***@163.com
  • 发布:2024-12-20 09:42
  • 更新:2024-12-20 09:49
  • 阅读:25

使用nvue页面还是还有必要使用条件编译APP-NVUE吗

分类:uni-app

再使用nvue开发页面时,在页面里还有必要写条件编译吗,例如官方HelloUniapp项目了的写法

<!-- #ifdef APP-NVUE -->  
<!-- #endif -->  
<!-- #ifndef APP-NVUE -->  
<!-- #endif -->
<template>  
    <view class="tabs">  
        <scroll-view id="tab-bar" class="scroll-h" :scroll-x="true" :show-scrollbar="false" :scroll-into-view="scrollInto">  
            <view v-for="(tab,index) in tabBars" :key="tab.id" class="uni-tab-item" :id="tab.id" :data-current="index" @click="ontabtap">  
                <text class="uni-tab-item-title" :class="tabIndex==index ? 'uni-tab-item-title-active' : ''">{{tab.name}}</text>  
            </view>  
        </scroll-view>  
        <view class="line-h"></view>  
        <swiper :current="tabIndex" class="swiper-box" style="flex: 1;" :duration="300" @change="ontabchange">  
            <swiper-item class="swiper-item" v-for="(tab,index1) in newsList" :key="index1">  
                <!-- #ifdef APP-NVUE -->  
                <list class="scroll-v list" enableBackToTop="true" scroll-y loadmoreoffset="15" @loadmore="loadMore(index1)">  
                    <refresh class="refresh" @refresh="onrefresh(index1)" @pullingdown="onpullingdown" :display="tab.refreshing ? 'show' : 'hide'">  
                        <div class="refresh-view">  
                            <image class="refresh-icon" :src="refreshIcon" :style="{width: (tab.refreshing || pulling) ? 0: '30px'}" :class="{'refresh-icon-active': tab.refreshFlag}"></image>  
                            <loading-indicator class="loading-icon" animating="true" v-if="tab.refreshing"></loading-indicator>  
                            <text class="loading-text">{{tab.refreshText}}</text>  
                        </div>  
                    </refresh>  
                    <cell v-for="(newsitem,index2) in tab.data" :key="newsitem.id">  
                        <media-item :options="newsitem" @close="close(index1,index2)" @click="goDetail(newsitem)"></media-item>  
                    </cell>  
                    <cell class="loading-more" v-if="tab.isLoading || tab.data.length > 4">  
                        <text class="loading-more-text">{{tab.loadingText}}</text>  
                    </cell>  
                </list>  
                <!-- #endif -->  
                <!-- #ifndef APP-NVUE -->  
                <scroll-view class="scroll-v list" enableBackToTop="true" scroll-y @scrolltolower="loadMore(index1)">  
                    <view v-for="(newsitem,index2) in tab.data" :key="newsitem.id">  
                        <media-item :options="newsitem" @close="close(index1,index2)" @click="goDetail(newsitem)"></media-item>  
                    </view>  
                    <view class="loading-more" v-if="tab.isLoading || tab.data.length > 4">  
                        <text class="loading-more-text">{{tab.loadingText}}</text>  
                    </view>  
                </scroll-view>  
                <!-- #endif -->  
            </swiper-item>  
        </swiper>  
    </view>  
</template>
2024-12-20 09:42 负责人:无 分享
已邀请:
爱豆豆

爱豆豆 - 办法总比困难多

看你实际的需求 如果你这个nvue页面 需要兼容h5和app的话 可能会用到条件编译
因为有些组件只能在app端使用 例如你截图的list组件 只能在app端使用 h5端只能用scroll-view 所以就要用到条件编译了

  • 1***@163.com (作者)

    谢谢了,在非 app 端,uni-app 编译模式的 nvue 文件也会被编译

    2024-12-20 10:11

要回复问题请先登录注册