Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vue3 在 v-if 中使用 wxs 报错 #3199

Closed
jin-yufeng opened this issue Jan 18, 2022 · 12 comments
Closed

vue3 在 v-if 中使用 wxs 报错 #3199

jin-yufeng opened this issue Jan 18, 2022 · 12 comments
Assignees
Labels
bug Something isn't working mp mini program vue3

Comments

@jin-yufeng
Copy link

问题描述
vue3v-if 中使用 wxs 报错,vue2 正常

复现步骤

<template>  
    <view>  
        <view v-if="test.aa()">123</view>  
    </view>  
</template>  
<script module="test" lang="wxs">  
    function aa() {  
        return true  
    }  
    module.exports = {  
        aa: aa  
    }  
</script>

vue 版本选择 3,运行到微信小程序

预期结果
正常运行

实际结果
报错 ReferenceError: test is not defined

系统信息:

  • 发行平台: 微信小程序
  • HBuilderX版本 3.3.8
@fxy060608 fxy060608 self-assigned this Jan 19, 2022
@fxy060608 fxy060608 added bug Something isn't working mp mini program vue3 labels Jan 19, 2022
@okxiaoliang4
Copy link

遇到同样问题

@fxy060608
Copy link
Collaborator

已修复,cli更新至:3.0.0-alpha-3030820220114003

@jin-yufeng
Copy link
Author

@fxy060608 app 端也有问题,虽然不会报错,但是 wxs 返回 false 还是会显示

@fxy060608
Copy link
Collaborator

@fxy060608 app 端也有问题,虽然不会报错,但是 wxs 返回 false 还是会显示

具体是什么样子的业务需求,需要在 if 里边访问 wxs 中的内容呢?是否有其他方案可以先绕过去

@okxiaoliang4
Copy link

@fxy060608 app 端也有问题,虽然不会报错,但是 wxs 返回 false 还是会显示

具体是什么样子的业务需求,需要在 if 里边访问 wxs 中的内容呢?是否有其他方案可以先绕过去

他需求应该是这个,我正好有在vue3.0用他的库适配的时候也是遇到一样问题
https://github.com/jin-yufeng/mp-html/blob/master/src/uni-app/components/mp-html/node/node.vue#L57

@jin-yufeng
Copy link
Author

不方便改的话我试试其他方案吧

@okxiaoliang4
Copy link

可以用computed先代替吧?

@okxiaoliang4
Copy link

之前wxs不行的时候我是先用computed代替了

@fxy060608
Copy link
Collaborator

不方便改的话我试试其他方案吧

建议可以先绕一下,app端修复这个问题会麻烦一些,时间上不一定保证

@okxiaoliang4
Copy link

@fxy060608 3.0.0-alpha-3031020220124001 这个版本wxs异常问题又出现了

@fxy060608
Copy link
Collaborator

@fxy060608 3.0.0-alpha-3031020220124001 这个版本wxs异常问题又出现了

锁死版本不使用^升级

@okxiaoliang4
Copy link

@fxy060608 3.0.0-alpha-3031020220124001 这个版本wxs异常问题又出现了

锁死版本不使用^升级

好的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working mp mini program vue3
Projects
None yet
Development

No branches or pull requests

3 participants