Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
erosXXX
uni-app
提交
7834536e
U
uni-app
项目概览
erosXXX
/
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,发现更多精彩内容 >>
提交
7834536e
编写于
4月 30, 2020
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(mp): dynamic event
上级
abd2cbb2
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
47 addition
and
10 deletion
+47
-10
packages/uni-migration/__tests__/demo.js
packages/uni-migration/__tests__/demo.js
+29
-6
packages/uni-migration/__tests__/wxml.spec.js
packages/uni-migration/__tests__/wxml.spec.js
+2
-2
packages/uni-migration/lib/mp-weixin/transform/template-transformer/transform/traverse.js
...ixin/transform/template-transformer/transform/traverse.js
+6
-2
packages/uni-mp-weixin/dist/mp.js
packages/uni-mp-weixin/dist/mp.js
+3
-0
src/core/runtime/mp/polyfill/index.js
src/core/runtime/mp/polyfill/index.js
+7
-0
未找到文件。
packages/uni-migration/__tests__/demo.js
浏览文件 @
7834536e
const
migrate
=
require
(
'
../lib/index
'
)
//
const migrate = require('../lib/index')
migrate
(
'
/Users/fxy/Downloads/wa-vantui_1.1
'
)
//
migrate('/Users/fxy/Downloads/wa-vantui_1.1')
// migrate('/Users/fxy/Downloads/wa-vantui_1.1/pages')
// migrate('/Users/fxy/Downloads/wa-vantui_1.1/pages')
// const {
const
{
// parse
parse
// } = require('mustache')
}
=
require
(
'
mustache
'
)
// console.log(parse("van-notice-bar__content {{ !scrollable && !wrapable ? 'van-ellipsis' : '' }}"))
function
parseMustache
(
expr
,
identifier
=
false
)
{
if
(
!
expr
)
{
return
''
}
const
tokens
=
parse
(
expr
)
const
isIdentifier
=
tokens
.
length
===
1
return
tokens
.
map
(
token
=>
{
if
(
token
[
0
]
===
'
text
'
)
{
if
(
identifier
)
{
return
token
[
1
]
}
return
`'
${
token
[
1
]}
'`
}
else
if
(
token
[
0
]
===
'
!
'
)
{
// {{ !loading }}
return
`(!
${
token
[
1
]}
)`
}
else
if
(
token
[
0
]
===
'
name
'
)
{
if
(
isIdentifier
)
{
return
token
[
1
]
}
return
`(
${
token
[
1
]}
)`
}
}).
join
(
'
+
'
)
}
console
.
log
(
parseMustache
(
"
click
"
,
true
)
===
'
click
'
)
// const {
// const {
// transformTemplate
// transformTemplate
...
...
packages/uni-migration/__tests__/wxml.spec.js
浏览文件 @
7834536e
...
@@ -9,11 +9,11 @@ describe('wxml:compiler', () => {
...
@@ -9,11 +9,11 @@ describe('wxml:compiler', () => {
it
(
'
generate event
'
,
()
=>
{
it
(
'
generate event
'
,
()
=>
{
assertCodegen
(
assertCodegen
(
`<view bindtouchstart="startDrag" catchtouchmove="{{ catchMove ? 'noop' : '' }}"/>`
,
`<view bindtouchstart="startDrag" catchtouchmove="{{ catchMove ? 'noop' : '' }}"/>`
,
`<uni-shadow-root><view @touchstart="startDrag" @touchmove.stop.prevent="
catchMove ? 'noop' : ''
"></view></uni-shadow-root>`
`<uni-shadow-root><view @touchstart="startDrag" @touchmove.stop.prevent="
_$self[(catchMove ? 'noop' : '')||'_$noop']($event)
"></view></uni-shadow-root>`
)
)
assertCodegen
(
assertCodegen
(
`<uni-transition bind:click="click" bindtouchstart="startDrag" catchtouchmove="{{ catchMove ? 'noop' : '' }}"/>`
,
`<uni-transition bind:click="click" bindtouchstart="startDrag" catchtouchmove="{{ catchMove ? 'noop' : '' }}"/>`
,
`<uni-shadow-root><uni-transition @click="click" @touchstart.native="startDrag" @touchmove.native.stop.prevent="
catchMove ? 'noop' : ''
"></uni-transition></uni-shadow-root>`
`<uni-shadow-root><uni-transition @click="click" @touchstart.native="startDrag" @touchmove.native.stop.prevent="
_$self[(catchMove ? 'noop' : '')||'_$noop']($event)
"></uni-transition></uni-shadow-root>`
)
)
})
})
it
(
'
generate class
'
,
()
=>
{
it
(
'
generate class
'
,
()
=>
{
...
...
packages/uni-migration/lib/mp-weixin/transform/template-transformer/transform/traverse.js
浏览文件 @
7834536e
...
@@ -127,7 +127,7 @@ function transformFor(attribs) {
...
@@ -127,7 +127,7 @@ function transformFor(attribs) {
if
(
vKey
)
{
if
(
vKey
)
{
if
(
vKey
===
'
*this
'
)
{
if
(
vKey
===
'
*this
'
)
{
vKey
=
vItem
vKey
=
vItem
}
else
if
(
vKey
!==
vItem
&&
vKey
.
indexOf
(
'
.
'
)
===-
1
)
{
// wx:for-key="{{item.value}}"
}
else
if
(
vKey
!==
vItem
&&
vKey
.
indexOf
(
'
.
'
)
===
-
1
)
{
// wx:for-key="{{item.value}}"
vKey
=
vItem
+
'
.
'
+
vKey
vKey
=
vItem
+
'
.
'
+
vKey
}
}
attribs
[
'
:key
'
]
=
vKey
attribs
[
'
:key
'
]
=
vKey
...
@@ -163,7 +163,11 @@ function transformEvent(name, value, attribs, state) {
...
@@ -163,7 +163,11 @@ function transformEvent(name, value, attribs, state) {
event
=
transformEventName
(
name
.
replace
(
captureCatchRE
,
''
),
state
)
+
'
.stop.prevent.capture
'
event
=
transformEventName
(
name
.
replace
(
captureCatchRE
,
''
),
state
)
+
'
.stop.prevent.capture
'
}
}
if
(
event
!==
name
)
{
if
(
event
!==
name
)
{
attribs
[
event
]
=
parseMustache
(
value
,
true
)
let
newValue
=
parseMustache
(
value
,
true
)
if
(
newValue
!==
value
)
{
newValue
=
`_$self[(
${
newValue
}
)||'_$noop']($event)`
}
attribs
[
event
]
=
newValue
return
true
return
true
}
}
}
}
...
...
packages/uni-mp-weixin/dist/mp.js
浏览文件 @
7834536e
...
@@ -758,6 +758,9 @@ var polyfill = {
...
@@ -758,6 +758,9 @@ var polyfill = {
beforeCreate
()
{
beforeCreate
()
{
// 取消 development 时的 Proxy,避免小程序组件模板中使用尚未定义的属性告警
// 取消 development 时的 Proxy,避免小程序组件模板中使用尚未定义的属性告警
this
.
_renderProxy
=
this
;
this
.
_renderProxy
=
this
;
this
.
_$self
=
this
;
this
.
_$noop
=
noop
;
},
},
created
()
{
// properties 中可能会访问 methods,故需要在 created 中初始化
created
()
{
// properties 中可能会访问 methods,故需要在 created 中初始化
initState
(
this
);
initState
(
this
);
...
...
src/core/runtime/mp/polyfill/index.js
浏览文件 @
7834536e
import
{
noop
}
from
'
uni-shared
'
import
{
import
{
initState
initState
}
from
'
./state/index
'
}
from
'
./state/index
'
...
@@ -19,6 +23,9 @@ export default {
...
@@ -19,6 +23,9 @@ export default {
beforeCreate
()
{
beforeCreate
()
{
// 取消 development 时的 Proxy,避免小程序组件模板中使用尚未定义的属性告警
// 取消 development 时的 Proxy,避免小程序组件模板中使用尚未定义的属性告警
this
.
_renderProxy
=
this
this
.
_renderProxy
=
this
this
.
_$self
=
this
this
.
_$noop
=
noop
},
},
created
()
{
// properties 中可能会访问 methods,故需要在 created 中初始化
created
()
{
// properties 中可能会访问 methods,故需要在 created 中初始化
initState
(
this
)
initState
(
this
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录