@mpxjs/webpack-plugin 2.8.64-bridgetest → 2.8.64
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/dependencies/DynamicEntryDependency.js +16 -10
- package/lib/index.js +25 -41
- package/lib/loader.js +23 -28
- package/lib/parser.js +1 -0
- package/lib/platform/template/wx/component-config/component.js +2 -1
- package/lib/platform/template/wx/index.js +24 -13
- package/lib/runtime/base.styl +1 -9
- package/lib/runtime/components/web/getInnerListeners.js +2 -1
- package/lib/runtime/components/web/mpx-image.vue +10 -13
- package/lib/runtime/components/web/mpx-movable-view.vue +1 -1
- package/lib/runtime/components/web/mpx-picker-view-column.vue +10 -2
- package/lib/runtime/components/web/mpx-picker.vue +9 -1
- package/lib/runtime/components/web/mpx-swiper.vue +2 -2
- package/lib/runtime/optionProcessor.js +264 -321
- package/lib/runtime/stringify.wxs +8 -44
- package/lib/template-compiler/compiler.js +50 -73
- package/lib/utils/get-entry-name.js +6 -4
- package/lib/web/processScript.js +203 -20
- package/lib/web/processTemplate.js +1 -4
- package/package.json +3 -3
- package/lib/web/processMainScript.js +0 -56
- package/lib/web/script-helper.js +0 -198
|
@@ -28,10 +28,23 @@ class DynamicEntryDependency extends NullDependency {
|
|
|
28
28
|
return toPosix([request, entryType, outputPath, packageRoot, relativePath, context, ...range].join('|'))
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
collectDynamicRequest (mpx) {
|
|
32
|
+
if (!this.packageRoot) return
|
|
33
|
+
const curValue = mpx.dynamicEntryInfo[this.packageRoot] = mpx.dynamicEntryInfo[this.packageRoot] || {
|
|
34
|
+
hasPage: false,
|
|
35
|
+
entries: []
|
|
36
|
+
}
|
|
37
|
+
if (this.entryType === 'page') {
|
|
38
|
+
curValue.hasPage = true
|
|
39
|
+
} else {
|
|
40
|
+
curValue.entries.push(this.request)
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
31
44
|
addEntry (compilation, callback) {
|
|
32
45
|
const mpx = compilation.__mpx__
|
|
33
46
|
let { request, entryType, outputPath, relativePath, context, originEntryNode, publicPath, resolver } = this
|
|
34
|
-
|
|
47
|
+
this.collectDynamicRequest(mpx)
|
|
35
48
|
async.waterfall([
|
|
36
49
|
(callback) => {
|
|
37
50
|
if (context && resolver) {
|
|
@@ -43,13 +56,12 @@ class DynamicEntryDependency extends NullDependency {
|
|
|
43
56
|
}
|
|
44
57
|
},
|
|
45
58
|
(resource, callback) => {
|
|
46
|
-
const { resourcePath } = parseRequest(resource)
|
|
47
|
-
|
|
48
59
|
if (!outputPath) {
|
|
60
|
+
const { resourcePath } = parseRequest(resource)
|
|
49
61
|
outputPath = mpx.getOutputPath(resourcePath, entryType)
|
|
50
62
|
}
|
|
51
63
|
|
|
52
|
-
const {
|
|
64
|
+
const { packageRoot, outputPath: filename, alreadyOutputted } = mpx.getPackageInfo({
|
|
53
65
|
resource,
|
|
54
66
|
outputPath,
|
|
55
67
|
resourceType: entryType,
|
|
@@ -104,12 +116,6 @@ class DynamicEntryDependency extends NullDependency {
|
|
|
104
116
|
.catch(err => callback(err))
|
|
105
117
|
|
|
106
118
|
mpx.addEntryPromiseMap.set(key, addEntryPromise)
|
|
107
|
-
mpx.collectDynamicEntryInfo({
|
|
108
|
-
resource,
|
|
109
|
-
packageName,
|
|
110
|
-
filename,
|
|
111
|
-
entryType
|
|
112
|
-
})
|
|
113
119
|
}
|
|
114
120
|
}
|
|
115
121
|
], callback)
|
package/lib/index.js
CHANGED
|
@@ -113,6 +113,7 @@ class MpxWebpackPlugin {
|
|
|
113
113
|
constructor (options = {}) {
|
|
114
114
|
options.mode = options.mode || 'wx'
|
|
115
115
|
options.env = options.env || ''
|
|
116
|
+
|
|
116
117
|
options.srcMode = options.srcMode || options.mode
|
|
117
118
|
if (options.mode !== options.srcMode && options.srcMode !== 'wx') {
|
|
118
119
|
errors.push('MpxWebpackPlugin supports srcMode to be "wx" only temporarily!')
|
|
@@ -493,17 +494,17 @@ class MpxWebpackPlugin {
|
|
|
493
494
|
}, (compilation, callback) => {
|
|
494
495
|
processSubpackagesEntriesMap(compilation, (err) => {
|
|
495
496
|
if (err) return callback(err)
|
|
496
|
-
const
|
|
497
|
-
for (const
|
|
498
|
-
const entryMap = mpx.dynamicEntryInfo[
|
|
499
|
-
if (
|
|
497
|
+
const checkRegisterPack = () => {
|
|
498
|
+
for (const packRoot in mpx.dynamicEntryInfo) {
|
|
499
|
+
const entryMap = mpx.dynamicEntryInfo[packRoot]
|
|
500
|
+
if (!entryMap.hasPage) {
|
|
500
501
|
// 引用未注册分包的所有资源
|
|
501
|
-
const
|
|
502
|
-
compilation.errors.push(new Error(`资源${
|
|
502
|
+
const strRequest = entryMap.entries.join(',')
|
|
503
|
+
compilation.errors.push(new Error(`资源${strRequest}目标是打入${packRoot}分包, 但是app.json中并未声明${packRoot}分包`))
|
|
503
504
|
}
|
|
504
505
|
}
|
|
505
506
|
}
|
|
506
|
-
|
|
507
|
+
checkRegisterPack()
|
|
507
508
|
callback()
|
|
508
509
|
})
|
|
509
510
|
})
|
|
@@ -563,8 +564,8 @@ class MpxWebpackPlugin {
|
|
|
563
564
|
})
|
|
564
565
|
|
|
565
566
|
compiler.hooks.thisCompilation.tap('MpxWebpackPlugin', (compilation, { normalModuleFactory }) => {
|
|
566
|
-
compilation.warnings.
|
|
567
|
-
compilation.errors.
|
|
567
|
+
compilation.warnings = compilation.warnings.concat(warnings)
|
|
568
|
+
compilation.errors = compilation.errors.concat(errors)
|
|
568
569
|
const moduleGraph = compilation.moduleGraph
|
|
569
570
|
|
|
570
571
|
if (!compilation.__mpx__) {
|
|
@@ -593,7 +594,7 @@ class MpxWebpackPlugin {
|
|
|
593
594
|
subpackagesEntriesMap: {},
|
|
594
595
|
replacePathMap: {},
|
|
595
596
|
exportModules: new Set(),
|
|
596
|
-
//
|
|
597
|
+
// 动态记录注册的分包与注册页面映射
|
|
597
598
|
dynamicEntryInfo: {},
|
|
598
599
|
// 记录entryModule与entryNode的对应关系,用于体积分析
|
|
599
600
|
entryNodeModulesMap: new Map(),
|
|
@@ -637,18 +638,6 @@ class MpxWebpackPlugin {
|
|
|
637
638
|
forceProxyEventRules: this.options.forceProxyEventRules,
|
|
638
639
|
enableRequireAsync: this.options.mode === 'wx' || (this.options.mode === 'ali' && this.options.enableAliRequireAsync),
|
|
639
640
|
partialCompile: this.options.partialCompile,
|
|
640
|
-
collectDynamicEntryInfo: ({ resource, packageName, filename, entryType }) => {
|
|
641
|
-
const curInfo = mpx.dynamicEntryInfo[packageName] = mpx.dynamicEntryInfo[packageName] || {
|
|
642
|
-
hasPage: false,
|
|
643
|
-
entries: []
|
|
644
|
-
}
|
|
645
|
-
if (entryType === 'page') curInfo.hasPage = true
|
|
646
|
-
curInfo.entries.push({
|
|
647
|
-
entryType,
|
|
648
|
-
resource,
|
|
649
|
-
filename
|
|
650
|
-
})
|
|
651
|
-
},
|
|
652
641
|
asyncSubpackageRules: this.options.asyncSubpackageRules,
|
|
653
642
|
optimizeRenderRules: this.options.optimizeRenderRules,
|
|
654
643
|
pathHash: (resourcePath) => {
|
|
@@ -657,7 +646,7 @@ class MpxWebpackPlugin {
|
|
|
657
646
|
}
|
|
658
647
|
return hash(resourcePath)
|
|
659
648
|
},
|
|
660
|
-
addEntry
|
|
649
|
+
addEntry (request, name, callback) {
|
|
661
650
|
const dep = EntryPlugin.createDependency(request, { name })
|
|
662
651
|
compilation.addEntry(compiler.context, dep, { name }, callback)
|
|
663
652
|
return dep
|
|
@@ -825,14 +814,10 @@ class MpxWebpackPlugin {
|
|
|
825
814
|
const rawProcessModuleDependencies = compilation.processModuleDependencies
|
|
826
815
|
compilation.processModuleDependencies = (module, callback) => {
|
|
827
816
|
const presentationalDependencies = module.presentationalDependencies || []
|
|
828
|
-
const errors = []
|
|
829
817
|
async.forEach(presentationalDependencies.filter((dep) => dep.mpxAction), (dep, callback) => {
|
|
830
|
-
dep.mpxAction(module, compilation,
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
})
|
|
834
|
-
}, () => {
|
|
835
|
-
compilation.errors.push(...errors)
|
|
818
|
+
dep.mpxAction(module, compilation, callback)
|
|
819
|
+
}, (err) => {
|
|
820
|
+
if (err) compilation.errors.push(err)
|
|
836
821
|
rawProcessModuleDependencies.call(compilation, module, callback)
|
|
837
822
|
})
|
|
838
823
|
}
|
|
@@ -918,17 +903,16 @@ class MpxWebpackPlugin {
|
|
|
918
903
|
}
|
|
919
904
|
|
|
920
905
|
// hack process https://github.com/webpack/webpack/issues/16045
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
// }
|
|
906
|
+
const _handleModuleBuildAndDependenciesRaw = compilation._handleModuleBuildAndDependencies
|
|
907
|
+
|
|
908
|
+
compilation._handleModuleBuildAndDependencies = (originModule, module, recursive, callback) => {
|
|
909
|
+
const rawCallback = callback
|
|
910
|
+
callback = (err) => {
|
|
911
|
+
if (err) return rawCallback(err)
|
|
912
|
+
return rawCallback(null, module)
|
|
913
|
+
}
|
|
914
|
+
return _handleModuleBuildAndDependenciesRaw.call(compilation, originModule, module, recursive, callback)
|
|
915
|
+
}
|
|
932
916
|
|
|
933
917
|
const rawEmitAsset = compilation.emitAsset
|
|
934
918
|
|
package/lib/loader.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const JSON5 = require('json5')
|
|
2
2
|
const parseComponent = require('./parser')
|
|
3
3
|
const createHelpers = require('./helpers')
|
|
4
|
+
const loaderUtils = require('loader-utils')
|
|
4
5
|
const parseRequest = require('./utils/parse-request')
|
|
5
6
|
const { matchCondition } = require('./utils/match-condition')
|
|
6
7
|
const addQuery = require('./utils/add-query')
|
|
@@ -19,7 +20,6 @@ const CommonJsVariableDependency = require('./dependencies/CommonJsVariableDepen
|
|
|
19
20
|
const tsWatchRunLoaderFilter = require('./utils/ts-loader-watch-run-loader-filter')
|
|
20
21
|
const { MPX_APP_MODULE_ID } = require('./utils/const')
|
|
21
22
|
const path = require('path')
|
|
22
|
-
const processMainScript = require('./web/processMainScript')
|
|
23
23
|
const getRulesRunner = require('./platform')
|
|
24
24
|
|
|
25
25
|
module.exports = function (content) {
|
|
@@ -85,6 +85,7 @@ module.exports = function (content) {
|
|
|
85
85
|
if (appName) this._module.addPresentationalDependency(new AppEntryDependency(resourcePath, appName))
|
|
86
86
|
}
|
|
87
87
|
const loaderContext = this
|
|
88
|
+
const stringifyRequest = r => loaderUtils.stringifyRequest(loaderContext, r)
|
|
88
89
|
const isProduction = this.minimize || process.env.NODE_ENV === 'production'
|
|
89
90
|
const filePath = this.resourcePath
|
|
90
91
|
const moduleId = ctorType === 'app' ? MPX_APP_MODULE_ID : 'm' + mpx.pathHash(filePath)
|
|
@@ -153,33 +154,23 @@ module.exports = function (content) {
|
|
|
153
154
|
// 处理mode为web时输出vue格式文件
|
|
154
155
|
if (mode === 'web') {
|
|
155
156
|
if (ctorType === 'app' && !queryObj.isApp) {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
tabBarMap: jsonRes.tabBarMap,
|
|
172
|
-
tabBarStr: jsonRes.tabBarStr,
|
|
173
|
-
localPagesMap: jsonRes.localPagesMap,
|
|
174
|
-
resource: this.resource
|
|
175
|
-
}, callback)
|
|
176
|
-
}
|
|
177
|
-
], (err, scriptRes) => {
|
|
178
|
-
if (err) return callback(err)
|
|
179
|
-
this.loaderIndex = -1
|
|
180
|
-
return callback(null, scriptRes.output)
|
|
181
|
-
})
|
|
157
|
+
const request = addQuery(this.resource, { isApp: true })
|
|
158
|
+
const el = mpx.webConfig.el || '#app'
|
|
159
|
+
output += `
|
|
160
|
+
import App from ${stringifyRequest(request)}
|
|
161
|
+
import Vue from 'vue'
|
|
162
|
+
new Vue({
|
|
163
|
+
el: '${el}',
|
|
164
|
+
render: function(h){
|
|
165
|
+
return h(App)
|
|
166
|
+
}
|
|
167
|
+
})\n
|
|
168
|
+
`
|
|
169
|
+
// 直接结束loader进入parse
|
|
170
|
+
this.loaderIndex = -1
|
|
171
|
+
return callback(null, output)
|
|
182
172
|
}
|
|
173
|
+
|
|
183
174
|
// 通过RecordVueContentDependency和vueContentCache确保子request不再重复生成vueContent
|
|
184
175
|
const cacheContent = mpx.vueContentCache.get(filePath)
|
|
185
176
|
if (cacheContent) return callback(null, cacheContent)
|
|
@@ -235,10 +226,13 @@ module.exports = function (content) {
|
|
|
235
226
|
componentGenerics,
|
|
236
227
|
jsonConfig: jsonRes.jsonObj,
|
|
237
228
|
outputPath: queryObj.outputPath || '',
|
|
229
|
+
tabBarMap: jsonRes.tabBarMap,
|
|
230
|
+
tabBarStr: jsonRes.tabBarStr,
|
|
238
231
|
builtInComponentsMap: templateRes.builtInComponentsMap,
|
|
239
232
|
genericsInfo: templateRes.genericsInfo,
|
|
240
233
|
wxsModuleMap: templateRes.wxsModuleMap,
|
|
241
|
-
localComponentsMap: jsonRes.localComponentsMap
|
|
234
|
+
localComponentsMap: jsonRes.localComponentsMap,
|
|
235
|
+
localPagesMap: jsonRes.localPagesMap
|
|
242
236
|
}, callback)
|
|
243
237
|
}
|
|
244
238
|
], (err, scriptRes) => {
|
|
@@ -248,6 +242,7 @@ module.exports = function (content) {
|
|
|
248
242
|
callback(null, output)
|
|
249
243
|
})
|
|
250
244
|
}
|
|
245
|
+
|
|
251
246
|
const moduleGraph = this._compilation.moduleGraph
|
|
252
247
|
|
|
253
248
|
const issuer = moduleGraph.getIssuer(this._module)
|
package/lib/parser.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
const
|
|
1
|
+
const templateCompiler = require('../../../../template-compiler/compiler')
|
|
2
|
+
const parseMustache = templateCompiler.parseMustache
|
|
2
3
|
const normalize = require('../../../../utils/normalize')
|
|
3
4
|
const TAG_NAME = 'component'
|
|
4
5
|
|
|
@@ -3,7 +3,9 @@ const JSON5 = require('json5')
|
|
|
3
3
|
const getComponentConfigs = require('./component-config')
|
|
4
4
|
const normalizeComponentRules = require('../normalize-component-rules')
|
|
5
5
|
const isValidIdentifierStr = require('../../../utils/is-valid-identifier-str')
|
|
6
|
-
const
|
|
6
|
+
const templateCompiler = require('../../../template-compiler/compiler')
|
|
7
|
+
const parseMustache = templateCompiler.parseMustache
|
|
8
|
+
const stringifyWithResolveComputed = templateCompiler.stringifyWithResolveComputed
|
|
7
9
|
const normalize = require('../../../utils/normalize')
|
|
8
10
|
|
|
9
11
|
module.exports = function getSpec ({ warn, error }) {
|
|
@@ -15,10 +17,10 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
15
17
|
postProps: [
|
|
16
18
|
{
|
|
17
19
|
web ({ name, value }) {
|
|
18
|
-
const parsed =
|
|
20
|
+
const parsed = parseMustache(value)
|
|
19
21
|
if (parsed.hasBinding) {
|
|
20
22
|
return {
|
|
21
|
-
name: name === 'animation' ? 'v-
|
|
23
|
+
name: name === 'animation' ? 'v-' + name : ':' + name,
|
|
22
24
|
value: parsed.result
|
|
23
25
|
}
|
|
24
26
|
}
|
|
@@ -32,7 +34,7 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
32
34
|
test: 'wx:for',
|
|
33
35
|
swan (obj, data) {
|
|
34
36
|
const attrsMap = data.el.attrsMap
|
|
35
|
-
const parsed =
|
|
37
|
+
const parsed = parseMustache(obj.value)
|
|
36
38
|
let listName = parsed.result
|
|
37
39
|
const el = data.el
|
|
38
40
|
|
|
@@ -46,7 +48,7 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
46
48
|
}
|
|
47
49
|
|
|
48
50
|
if (keyName) {
|
|
49
|
-
const parsed =
|
|
51
|
+
const parsed = parseMustache(keyName)
|
|
50
52
|
if (parsed.hasBinding) {
|
|
51
53
|
// keyStr = ` trackBy ${parsed.result.slice(1, -1)}`
|
|
52
54
|
} else if (keyName === '*this') {
|
|
@@ -76,7 +78,7 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
76
78
|
}
|
|
77
79
|
},
|
|
78
80
|
web ({ value }, { el }) {
|
|
79
|
-
const parsed =
|
|
81
|
+
const parsed = parseMustache(value)
|
|
80
82
|
const attrsMap = el.attrsMap
|
|
81
83
|
const itemName = attrsMap['wx:for-item'] || 'item'
|
|
82
84
|
const indexName = attrsMap['wx:for-index'] || 'index'
|
|
@@ -188,8 +190,9 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
188
190
|
}
|
|
189
191
|
const styleBinding = []
|
|
190
192
|
el.isStyleParsed = true
|
|
193
|
+
// 不过滤的话每一个属性都要 parse
|
|
191
194
|
el.attrsList.filter(item => this.test.test(item.name)).forEach((item) => {
|
|
192
|
-
const parsed =
|
|
195
|
+
const parsed = parseMustache(item.value)
|
|
193
196
|
styleBinding.push(parsed.result)
|
|
194
197
|
})
|
|
195
198
|
return {
|
|
@@ -200,12 +203,20 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
200
203
|
},
|
|
201
204
|
{
|
|
202
205
|
// 样式类名绑定
|
|
203
|
-
test: /^wx:
|
|
204
|
-
web ({ value }) {
|
|
205
|
-
|
|
206
|
+
test: /^(class|wx:class)$/,
|
|
207
|
+
web ({ value }, { el }) {
|
|
208
|
+
if (el.isClassParsed) {
|
|
209
|
+
return false
|
|
210
|
+
}
|
|
211
|
+
const classBinding = []
|
|
212
|
+
el.isClassParsed = true
|
|
213
|
+
el.attrsList.filter(item => this.test.test(item.name)).forEach((item) => {
|
|
214
|
+
const parsed = parseMustache(item.value)
|
|
215
|
+
classBinding.push(parsed.result)
|
|
216
|
+
})
|
|
206
217
|
return {
|
|
207
218
|
name: ':class',
|
|
208
|
-
value:
|
|
219
|
+
value: `[${classBinding}]`
|
|
209
220
|
}
|
|
210
221
|
}
|
|
211
222
|
},
|
|
@@ -256,7 +267,7 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
256
267
|
},
|
|
257
268
|
web ({ name, value }) {
|
|
258
269
|
let dir = this.test.exec(name)[1]
|
|
259
|
-
const parsed =
|
|
270
|
+
const parsed = parseMustache(value)
|
|
260
271
|
if (dir === 'elif') {
|
|
261
272
|
dir = 'else-if'
|
|
262
273
|
}
|
|
@@ -356,7 +367,7 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
356
367
|
}
|
|
357
368
|
},
|
|
358
369
|
web ({ name, value }, { eventRules, el, usingComponents }) {
|
|
359
|
-
if (
|
|
370
|
+
if (parseMustache(value).hasBinding) {
|
|
360
371
|
error('Web environment does not support mustache binding in event props!')
|
|
361
372
|
return
|
|
362
373
|
}
|
package/lib/runtime/base.styl
CHANGED
|
@@ -48,17 +48,9 @@ span {
|
|
|
48
48
|
white-space: pre-line;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
html, body,
|
|
52
|
-
display: block;
|
|
53
|
-
width: 100%;
|
|
54
|
-
height: 100%;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
page {
|
|
58
|
-
display: block;
|
|
51
|
+
html, body, .app {
|
|
59
52
|
width: 100%;
|
|
60
53
|
height: 100%;
|
|
61
|
-
background-color: #fff;
|
|
62
54
|
}
|
|
63
55
|
|
|
64
56
|
.pull-down-loading {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { isEmptyObject } from '../../utils'
|
|
2
2
|
import { isBrowser } from '../../env'
|
|
3
3
|
|
|
4
|
+
const isTouchDevice = isBrowser ? document && ('ontouchstart' in document.documentElement) : true
|
|
5
|
+
|
|
4
6
|
function processModel (listeners, context) {
|
|
5
7
|
// 该函数只有wx:model的情况下才调用,而且默认e.detail.value有值
|
|
6
8
|
// 该函数必须在产生merge前执行
|
|
@@ -47,7 +49,6 @@ function mergeListeners (listeners, otherListeners, options = {}) {
|
|
|
47
49
|
function processTap (listeners, context) {
|
|
48
50
|
const listenerMap = {}
|
|
49
51
|
const tapEvents = ['tap', 'longpress', 'longtap']
|
|
50
|
-
const isTouchDevice = isBrowser ? document && ('ontouchstart' in document.documentElement) : true
|
|
51
52
|
tapEvents.forEach((eventName) => {
|
|
52
53
|
if (listeners[eventName]) {
|
|
53
54
|
listenerMap[eventName] = true
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
import getInnerListeners, { getCustomEvent } from './getInnerListeners'
|
|
3
|
-
import { isBrowser } from '../../env'
|
|
4
3
|
|
|
5
4
|
export default {
|
|
6
5
|
name: 'mpx-image',
|
|
@@ -22,23 +21,21 @@
|
|
|
22
21
|
}
|
|
23
22
|
},
|
|
24
23
|
beforeCreate () {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
this
|
|
28
|
-
this
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
this
|
|
34
|
-
this.$emit('error', getCustomEvent('error', {}, this))
|
|
35
|
-
}
|
|
24
|
+
this.image = new Image()
|
|
25
|
+
this.image.onload = () => {
|
|
26
|
+
this.$emit('load', getCustomEvent('load', {
|
|
27
|
+
width: this.image.width,
|
|
28
|
+
height: this.image.height
|
|
29
|
+
}, this))
|
|
30
|
+
}
|
|
31
|
+
this.image.onerror = () => {
|
|
32
|
+
this.$emit('error', getCustomEvent('error', {}, this))
|
|
36
33
|
}
|
|
37
34
|
},
|
|
38
35
|
watch: {
|
|
39
36
|
src: {
|
|
40
37
|
handler (src) {
|
|
41
|
-
if (src
|
|
38
|
+
if (src) this.image.src = src
|
|
42
39
|
},
|
|
43
40
|
immediate: true
|
|
44
41
|
}
|
|
@@ -178,7 +178,7 @@
|
|
|
178
178
|
this.refresh()
|
|
179
179
|
})
|
|
180
180
|
const elementToObserve = document.querySelector('.mpx-movable-scroll-content')
|
|
181
|
-
this.resizeObserver.observe(elementToObserve)
|
|
181
|
+
elementToObserve && this.resizeObserver.observe(elementToObserve)
|
|
182
182
|
}
|
|
183
183
|
},
|
|
184
184
|
refresh () {
|
|
@@ -15,7 +15,13 @@
|
|
|
15
15
|
export default {
|
|
16
16
|
name: 'mpx-picker-view-column',
|
|
17
17
|
props: {
|
|
18
|
-
value: Array
|
|
18
|
+
value: Array,
|
|
19
|
+
scrollOptions: {
|
|
20
|
+
type: Object,
|
|
21
|
+
default: () => {
|
|
22
|
+
return {}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
19
25
|
},
|
|
20
26
|
data() {
|
|
21
27
|
return {
|
|
@@ -64,7 +70,9 @@
|
|
|
64
70
|
rotate: -5,
|
|
65
71
|
wheelWrapperClass: 'wheel-scroll'
|
|
66
72
|
},
|
|
67
|
-
probeType: 3
|
|
73
|
+
probeType: 3,
|
|
74
|
+
bindToWrapper: true,
|
|
75
|
+
...this.scrollOptions
|
|
68
76
|
})
|
|
69
77
|
this.wheels[0].on('scrollStart', function () {
|
|
70
78
|
if (this.pickerView) {
|
|
@@ -138,6 +138,12 @@
|
|
|
138
138
|
fields: {
|
|
139
139
|
type: String,
|
|
140
140
|
default: 'day'
|
|
141
|
+
},
|
|
142
|
+
scrollOptions: {
|
|
143
|
+
type: Object,
|
|
144
|
+
default: () => {
|
|
145
|
+
return {}
|
|
146
|
+
}
|
|
141
147
|
}
|
|
142
148
|
},
|
|
143
149
|
data () {
|
|
@@ -311,7 +317,9 @@
|
|
|
311
317
|
wheelWrapperClass: 'wheel-scroll',
|
|
312
318
|
wheelItemClass: 'wheel-item'
|
|
313
319
|
},
|
|
314
|
-
probeType: 3
|
|
320
|
+
probeType: 3,
|
|
321
|
+
bindToWrapper: true,
|
|
322
|
+
...this.scrollOptions
|
|
315
323
|
})
|
|
316
324
|
if (this.mode === 'time' || this.mode === 'date') {
|
|
317
325
|
this.wheels[i].on('scrollStart', function (i) {
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
default: () => {
|
|
48
48
|
return {}
|
|
49
49
|
}
|
|
50
|
-
}
|
|
50
|
+
}
|
|
51
51
|
},
|
|
52
52
|
data () {
|
|
53
53
|
return {
|
|
@@ -212,7 +212,7 @@
|
|
|
212
212
|
this.bs.scroller.hooks.on('beforeRefresh', () => {
|
|
213
213
|
this.initLayerComputed()
|
|
214
214
|
})
|
|
215
|
-
this.bs.on('
|
|
215
|
+
this.bs.on('slidePageChanged', (page) => {
|
|
216
216
|
this.currentIndex = this.vertical ? page.pageY : page.pageX
|
|
217
217
|
this.$emit('change', getCustomEvent('change', {
|
|
218
218
|
current: this.currentIndex,
|