照相
照相
  • 发布:2022-01-02 17:41
  • 更新:2022-10-02 01:00
  • 阅读:698

在升级vue3后使用vite编译时,js部分不是写在xxx.vue中,而是通过src引入时,js代码中的条件编译无效

分类:uni-app

产品分类: uniapp/H5

PC开发环境操作系统: Mac

PC开发环境操作系统版本号: macOS Big Sur 11.6

HBuilderX类型: 正式

HBuilderX版本号: 3.3.5

浏览器平台: Chrome

浏览器版本: 96.0.4664.110

项目创建方式: HBuilderX

示例代码:

index.vue代码

<template>  
    <view class="content">  
        <image class="logo" src="/static/logo.png"></image>  
        <view class="text-area">  
            <text class="title">{{title}}</text>  
        </view>  
    </view>  
</template>  

<script src="./test.js"></script>  

<style>  
    .content {  
        display: flex;  
        flex-direction: column;  
        align-items: center;  
        justify-content: center;  
    }  

    .logo {  
        height: 200rpx;  
        width: 200rpx;  
        margin-top: 200rpx;  
        margin-left: auto;  
        margin-right: auto;  
        margin-bottom: 50rpx;  
    }  

    .text-area {  
        display: flex;  
        justify-content: center;  
    }  

    .title {  
        font-size: 36rpx;  
        color: #8f8f94;  
    }  
</style>  

test.js代码

export default {  
    data() {  
        return {  
            title: 'Hello'  
        }  
    },  
    onLoad() {  
        // #ifdef APP-NVUE  
        console.log('This is APP-NVUE')  
        // #endif  
    },  
    methods: {  

    }  
}

操作步骤:

运行demo项目至浏览器,查看浏览器打印,显示了'This is APP-NVUE'的打印信息,说明条件编译失效。

预期结果:

运行demo项目至浏览器,查看浏览器打印,不应该显示'This is APP-NVUE'的打印信息。

实际结果:

运行demo项目至浏览器,查看浏览器打印,显示了'This is APP-NVUE'的打印信息,说明条件编译失效。

bug描述:

在升级vue3后使用vite编译时,js部分不是写在xxx.vue中,而是通过src引入时,js代码中的条件编译无效

2022-01-02 17:41 负责人:无 分享
已邀请:
DCloud_UNI_FXY

DCloud_UNI_FXY

已确认,下个版本修复

h***@sina.com

h***@sina.com

这个BUG在3.6.4中依然存在

要回复问题请先登录注册