8***@qq.com
8***@qq.com
  • 发布:2023-01-18 21:44
  • 更新:2023-04-11 14:33
  • 阅读:280

uniapp-vue3+vite项目在微信小程序中,使用wxs,传入响应数据作为参数获取不到

分类:uni-app

环境:node v18, vue3 vite编译有问题
代码如下:

<script module="utilTe" lang="wxs">  
var barWidth = function(index){  
console.log(11111,index)  
    var res = (200 * index) / 5;  
    return res;  
};  

var barColor = function(index){  
console.log(22222,index)  
    var barBgColor = ['#6033FF','#4B87FF','#37C2BC','#FFAA32'];  
    return barBgColor[index];  
};  
module.exports = {  
    barWidth:barWidth,  
    barColor: barColor  

}  
</script>  
<template>  
<view>{{test.a}}-{{utilTe.barWidth(test.a)}}</view>  
</template>  
<script lang="ts" setup>  
let test =reactive({  
    a:1  
})

</script>
问题:utilTe.barWidth(test.a) 执行获取参数为undefined。(使用vue3 ts vue-cli构建没这个问题)下图:

编译成小程序代码文件:


如果小程序代码中{{a}}- {{util.barWidth($data.test)}}改为{{a}}- {{util.barWidth(a)}}一切正常了,看似是个bug。

2023-01-18 21:44 负责人:无 分享
已邀请:
踽踽独行

踽踽独行

是有这个问题。wxs 传入响应式数据调用,全是undefined

要回复问题请先登录注册