Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
淡定0928
uni-app
提交
c78bf406
U
uni-app
项目概览
淡定0928
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
c78bf406
编写于
1月 11, 2023
作者:
Q
qiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(mp-weixin): array.length with multiple logicalExpression #1827
上级
f3fde1b1
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
24 addition
and
0 deletion
+24
-0
packages/uni-template-compiler/__tests__/compiler-mp-weixin.spec.js
...ni-template-compiler/__tests__/compiler-mp-weixin.spec.js
+15
-0
packages/uni-template-compiler/lib/script/traverse/visitor.js
...ages/uni-template-compiler/lib/script/traverse/visitor.js
+9
-0
未找到文件。
packages/uni-template-compiler/__tests__/compiler-mp-weixin.spec.js
浏览文件 @
c78bf406
...
...
@@ -376,6 +376,11 @@ describe('mp:compiler-mp-weixin', () => {
'
<button disabled="{{$root.g0===0}}">hello world</button>
'
,
'
with(this){var g0=array.length;$mp.data=Object.assign({},{$root:{g0:g0}})}
'
)
assertCodegen
(
'
<button :disabled="array.test&&test(array.test.test).length===0">hello world</button>
'
,
'
<button disabled="{{$root.g0}}">hello world</button>
'
,
'
with(this){var g0=array.test&&test(array.test.test).length===0;$mp.data=Object.assign({},{$root:{g0:g0}})}
'
)
assertCodegen
(
'
<view :class="
\'
c
\'
+array.length">hello world</view>
'
,
'
<view class="{{[
\'
c
\'
+$root.g0]}}">hello world</view>
'
,
...
...
@@ -391,6 +396,16 @@ describe('mp:compiler-mp-weixin', () => {
'
<block wx:if="{{$root.g0}}"><view>hello</view></block>
'
,
'
with(this){var g0=array.length;$mp.data=Object.assign({},{$root:{g0:g0}})}
'
)
assertCodegen
(
'
<view v-if="array&&array.length">hello</view>
'
,
'
<block wx:if="{{$root.g0}}"><view>hello</view></block>
'
,
'
with(this){var g0=array&&array.length;$mp.data=Object.assign({},{$root:{g0:g0}})}
'
)
assertCodegen
(
'
<view v-if="test1&&!test2&&array&&array.length">hello</view>
'
,
'
<block wx:if="{{$root.g0}}"><view>hello</view></block>
'
,
'
with(this){var g0=test1&&!test2&&array&&array.length;$mp.data=Object.assign({},{$root:{g0:g0}})}
'
)
assertCodegen
(
'
<view v-show="array.length">hello</view>
'
,
'
<view hidden="{{!($root.g0)}}">hello</view>
'
,
...
...
packages/uni-template-compiler/lib/script/traverse/visitor.js
浏览文件 @
c78bf406
...
...
@@ -151,6 +151,15 @@ module.exports = {
}
// 微信小程序平台无法观测 Array length 访问:https://developers.weixin.qq.com/community/develop/doc/000c8ee47d87a0d5b6685a8cb57000
if
(
this
.
options
.
platform
.
name
===
'
mp-weixin
'
&&
hasLengthProperty
(
path
))
{
let
newPath
=
path
while
(
newPath
)
{
path
=
newPath
newPath
=
path
.
findParent
((
path
)
=>
path
.
isLogicalExpression
())
}
path
.
skip
()
if
(
path
.
findParent
((
path
)
=>
path
.
shouldSkip
))
{
return
}
path
.
replaceWith
(
getMemberExpr
(
path
,
IDENTIFIER_GLOBAL
,
path
.
node
,
this
))
}
},
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录