@dolphinweex/weex-harmony 0.1.0
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/README.md +13 -0
- package/index.js +2 -0
- package/package.json +37 -0
- package/src/components/baseSameLayer.vue +101 -0
- package/src/components/drag-vertical-list-view.vue +86 -0
- package/src/components/hl-button-base.vue +66 -0
- package/src/components/hl-button.vue +115 -0
- package/src/components/hl-image-base.vue +53 -0
- package/src/components/hl-image.vue +151 -0
- package/src/components/hl-lottie-base.vue +151 -0
- package/src/components/hl-lottie.vue +214 -0
- package/src/components/hl-richtext-base.vue +40 -0
- package/src/components/hl-richtext.vue +118 -0
- package/src/components/hl-slider-base.vue +75 -0
- package/src/components/hl-slider.vue +126 -0
- package/src/components/hl-textarea-base.vue +40 -0
- package/src/components/hl-textarea.vue +118 -0
- package/src/components/hl-video-base.vue +65 -0
- package/src/components/hl-video.vue +148 -0
- package/src/components/hl-web-base.vue +85 -0
- package/src/components/mdiea-arc-slider.vue +75 -0
- package/src/components/midea-apng-view-base.vue +111 -0
- package/src/components/midea-barchart-view.vue +56 -0
- package/src/components/midea-blur-view.vue +57 -0
- package/src/components/midea-calendar-pave.vue +64 -0
- package/src/components/midea-camera-view.vue +91 -0
- package/src/components/midea-circle-progress.vue +56 -0
- package/src/components/midea-combinechart-view.vue +56 -0
- package/src/components/midea-common-weex-view.vue +55 -0
- package/src/components/midea-drag-list-view.vue +89 -0
- package/src/components/midea-drag-slider-base.vue +66 -0
- package/src/components/midea-dragging-linechart-view.vue +56 -0
- package/src/components/midea-gesture-password-base.vue +63 -0
- package/src/components/midea-ijkplayer-view.vue +93 -0
- package/src/components/midea-linechart-view.vue +56 -0
- package/src/components/midea-lottie-view.vue +69 -0
- package/src/components/midea-map-view.vue +74 -0
- package/src/components/midea-pdf-view-base.vue +75 -0
- package/src/components/midea-picker.vue +58 -0
- package/src/components/midea-piechart-view.vue +56 -0
- package/src/components/midea-progresscycle-view.vue +56 -0
- package/src/components/midea-seek-bar-base.vue +136 -0
- package/src/components/midea-time-pave.vue +58 -0
- package/src/components/midea-video.vue +91 -0
- package/src/components/midea-vslider-bar-base.vue +89 -0
- package/src/components/pick-pallet.vue +66 -0
- package/src/index.js +180 -0
- package/src/transform-loader.js +249 -0
package/README.md
ADDED
package/index.js
ADDED
package/package.json
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
{
|
2
|
+
"name": "@dolphinweex/weex-harmony",
|
3
|
+
"version": "0.1.0",
|
4
|
+
"description": "weex harmony adapter",
|
5
|
+
"main": "index.js",
|
6
|
+
"files": [
|
7
|
+
"index.js",
|
8
|
+
"src/"
|
9
|
+
],
|
10
|
+
"scripts": {},
|
11
|
+
"dependencies": {
|
12
|
+
"fs-extra": "10.0.1",
|
13
|
+
"istanbul-lib-coverage": "3.2.0",
|
14
|
+
"istanbul-lib-report": "3.0.0",
|
15
|
+
"istanbul-reports": "3.1.5",
|
16
|
+
"nyc": "15.1.0",
|
17
|
+
"source-map": "0.7.4",
|
18
|
+
"css-loader": "^0.28.8",
|
19
|
+
"vue-loader": "^15.2.6",
|
20
|
+
"vue-style-loader": "^4.1.1",
|
21
|
+
"vue-template-compiler": "^2.6.11",
|
22
|
+
"himalaya": "^1.1.0",
|
23
|
+
"babel-core": "^6.26.0",
|
24
|
+
"babel-eslint": "^10.0.2",
|
25
|
+
"babel-loader": "^7.1.1",
|
26
|
+
"babel-plugin-component": "^1.1.1",
|
27
|
+
"babel-plugin-transform-runtime": "^6.23.0",
|
28
|
+
"babel-preset-stage-0": "^6.24.1",
|
29
|
+
"@dolphinweex/weex-harmony-transform": "0.1.0"
|
30
|
+
},
|
31
|
+
"repository": {
|
32
|
+
"type": "git",
|
33
|
+
"url": ""
|
34
|
+
},
|
35
|
+
"keyword": [],
|
36
|
+
"devDependencies": {}
|
37
|
+
}
|
@@ -0,0 +1,101 @@
|
|
1
|
+
<template>
|
2
|
+
<div>
|
3
|
+
<embed
|
4
|
+
:id="embedId"
|
5
|
+
:type="embedType"
|
6
|
+
:width="embedWidth"
|
7
|
+
:height="embedHeight"
|
8
|
+
/>
|
9
|
+
</div>
|
10
|
+
</template>
|
11
|
+
|
12
|
+
<script>
|
13
|
+
const weexModule = weex.requireModule("weexModule");
|
14
|
+
|
15
|
+
export default {
|
16
|
+
name: "BaseSameLayer",
|
17
|
+
props: {
|
18
|
+
hosSameLayerArgs: {
|
19
|
+
type: Object,
|
20
|
+
required: true
|
21
|
+
},
|
22
|
+
embedType: {
|
23
|
+
type: String,
|
24
|
+
required: true,
|
25
|
+
},
|
26
|
+
defaultWidth: {
|
27
|
+
type: Number,
|
28
|
+
required: false,
|
29
|
+
default: 0,
|
30
|
+
},
|
31
|
+
defaultHeight: {
|
32
|
+
type: Number,
|
33
|
+
required: false,
|
34
|
+
default: 0,
|
35
|
+
},
|
36
|
+
},
|
37
|
+
data() {
|
38
|
+
return {
|
39
|
+
embedId: `embed_${this._uid}`, // 使用Vue实例的唯一ID来生成embed元素的唯一ID
|
40
|
+
};
|
41
|
+
},
|
42
|
+
computed: {
|
43
|
+
embedWidth() {
|
44
|
+
// 如果hosSameLayerArgs.width存在且定义了,则使用该值,否则使用defaultWidth
|
45
|
+
return this.hosSameLayerArgs.width || this.defaultWidth;
|
46
|
+
},
|
47
|
+
embedHeight() {
|
48
|
+
// 如果hosSameLayerArgs.height存在且定义了,则使用该值,否则使用defaultHeight
|
49
|
+
return this.hosSameLayerArgs.height || this.defaultHeight;
|
50
|
+
},
|
51
|
+
},
|
52
|
+
created() {
|
53
|
+
console.log("[sameLayerRendering] web component created.");
|
54
|
+
weexModule.callNative("transferSameLayerArgs", {
|
55
|
+
componentId: this.embedId,
|
56
|
+
...this.hosSameLayerArgs,
|
57
|
+
});
|
58
|
+
},
|
59
|
+
mounted() {
|
60
|
+
console.log("[sameLayerRendering] web component mounted.");
|
61
|
+
this.addTouchEvent();
|
62
|
+
},
|
63
|
+
beforeDestroy() {
|
64
|
+
console.log("[sameLayerRendering] web component beforeDestroy.");
|
65
|
+
this.removeTouchEvent();
|
66
|
+
},
|
67
|
+
methods: {
|
68
|
+
// 必须给embed元素添加touchstart事件监听,addEventListener的第二个参数监听事件对象置空即可(同层渲染事件处理需要)
|
69
|
+
addTouchEvent() {
|
70
|
+
const embedElement = document.getElementById(this.embedId);
|
71
|
+
if (embedElement) {
|
72
|
+
console.log(
|
73
|
+
"[sameLayerRendering] web component embed addEventListener."
|
74
|
+
);
|
75
|
+
embedElement.addEventListener("touchstart", {});
|
76
|
+
}
|
77
|
+
},
|
78
|
+
removeTouchEvent() {
|
79
|
+
const embedElement = document.getElementById(this.embedId);
|
80
|
+
if (embedElement) {
|
81
|
+
console.log(
|
82
|
+
"[sameLayerRendering] web component embed removeEventListener."
|
83
|
+
);
|
84
|
+
embedElement.removeEventListener("touchstart", {});
|
85
|
+
}
|
86
|
+
},
|
87
|
+
},
|
88
|
+
watch: {
|
89
|
+
hosSameLayerArgs: {
|
90
|
+
deep: true,
|
91
|
+
handler: function (newVal, oldVal) {
|
92
|
+
console.log("[sameLayerRendering] web component update.");
|
93
|
+
weexModule.callNative("transferSameLayerArgs", {
|
94
|
+
componentId: this.embedId,
|
95
|
+
...newVal,
|
96
|
+
});
|
97
|
+
},
|
98
|
+
},
|
99
|
+
},
|
100
|
+
};
|
101
|
+
</script>
|
@@ -0,0 +1,86 @@
|
|
1
|
+
<template>
|
2
|
+
<BaseSameLayer
|
3
|
+
:hosSameLayerArgs="hosSameLayerArgs"
|
4
|
+
embedType="native/drag-vertical-list-view"
|
5
|
+
:defaultWidth="300"
|
6
|
+
:defaultHeight="500"
|
7
|
+
></BaseSameLayer>
|
8
|
+
</template>
|
9
|
+
|
10
|
+
<script>
|
11
|
+
import BaseSameLayer from "./baseSameLayer.vue";
|
12
|
+
|
13
|
+
export default {
|
14
|
+
data() {
|
15
|
+
return {
|
16
|
+
width: 0,
|
17
|
+
height: 0,
|
18
|
+
};
|
19
|
+
},
|
20
|
+
name: "DragVerticalListView",
|
21
|
+
components: {
|
22
|
+
BaseSameLayer,
|
23
|
+
},
|
24
|
+
props: {
|
25
|
+
hosUniqueProps: {
|
26
|
+
type: Object,
|
27
|
+
default() {
|
28
|
+
return {};
|
29
|
+
},
|
30
|
+
},
|
31
|
+
data: {
|
32
|
+
type: Object,
|
33
|
+
default() {
|
34
|
+
return {};
|
35
|
+
},
|
36
|
+
},
|
37
|
+
},
|
38
|
+
computed: {
|
39
|
+
hosSameLayerArgs() {
|
40
|
+
return {
|
41
|
+
...this.hosUniqueProps, // 鸿蒙原生组件独有属性
|
42
|
+
width: this.width,
|
43
|
+
height: this.height,
|
44
|
+
data: this.data,
|
45
|
+
handleOnClick: this.handleOnClick,
|
46
|
+
handleOnDelete: this.handleOnDelete,
|
47
|
+
handleOnDragEnd: this.handleOnDragEnd,
|
48
|
+
handleOnCheck: this.handleOnCheck,
|
49
|
+
handleOnLongPress: this.handleOnLongPress,
|
50
|
+
handleOnSwitchCheck: this.handleOnSwitchCheck,
|
51
|
+
handleOnSwipeItemClick: this.handleOnSwipeItemClick
|
52
|
+
};
|
53
|
+
},
|
54
|
+
},
|
55
|
+
mounted() {
|
56
|
+
this.width = this.$el.clientWidth;
|
57
|
+
this.height = this.$el.clientHeight;
|
58
|
+
},
|
59
|
+
|
60
|
+
methods: {
|
61
|
+
// 自定义拓展其它逻辑
|
62
|
+
handleOnClick(res) {
|
63
|
+
this.$emit("onClickEvent", res);
|
64
|
+
},
|
65
|
+
handleOnDelete(res) {
|
66
|
+
this.$emit("onDeleteEvent", res);
|
67
|
+
},
|
68
|
+
handleOnDragEnd(res) {
|
69
|
+
this.$emit("onDragEndEvent", res);
|
70
|
+
},
|
71
|
+
handleOnCheck(res) {
|
72
|
+
this.$emit("onCheckEvent", res);
|
73
|
+
},
|
74
|
+
handleOnLongPress(res) {
|
75
|
+
this.$emit("onLongPressDragListView", res);
|
76
|
+
},
|
77
|
+
handleOnSwitchCheck(res) {
|
78
|
+
this.$emit("onSwitchCheck", res);
|
79
|
+
},
|
80
|
+
handleOnSwipeItemClick(res) {
|
81
|
+
this.$emit("onSwipeItemClick", res);
|
82
|
+
}
|
83
|
+
},
|
84
|
+
};
|
85
|
+
</script>
|
86
|
+
|
@@ -0,0 +1,66 @@
|
|
1
|
+
<template>
|
2
|
+
<BaseSameLayer
|
3
|
+
:hosSameLayerArgs="hosSameLayerArgs"
|
4
|
+
embedType="native/button"
|
5
|
+
:defaultWidth="300"
|
6
|
+
:defaultHeight="120"
|
7
|
+
></BaseSameLayer>
|
8
|
+
</template>
|
9
|
+
|
10
|
+
<script>
|
11
|
+
import BaseSameLayer from "./baseSameLayer.vue";
|
12
|
+
|
13
|
+
export default {
|
14
|
+
name: "HlButton",
|
15
|
+
components: {
|
16
|
+
BaseSameLayer,
|
17
|
+
},
|
18
|
+
props: {
|
19
|
+
hosUniqueProps: {
|
20
|
+
type: Object,
|
21
|
+
required: true,
|
22
|
+
},
|
23
|
+
text: {
|
24
|
+
type: String,
|
25
|
+
required: false,
|
26
|
+
},
|
27
|
+
loading: {
|
28
|
+
type: Boolean,
|
29
|
+
required: true
|
30
|
+
},
|
31
|
+
stateEffect: {
|
32
|
+
type: Boolean,
|
33
|
+
required: true
|
34
|
+
}
|
35
|
+
},
|
36
|
+
|
37
|
+
computed: {
|
38
|
+
hosSameLayerArgs() {
|
39
|
+
return {
|
40
|
+
...this.hosUniqueProps, // 鸿蒙原生组件独有属性
|
41
|
+
text: this.text,
|
42
|
+
loading: this.loading,
|
43
|
+
stateEffect: this.stateEffect,
|
44
|
+
handleOnTap: this.handleOnTap,
|
45
|
+
}
|
46
|
+
}
|
47
|
+
},
|
48
|
+
methods: {
|
49
|
+
// 自定义拓展其它逻辑
|
50
|
+
handleOnTap(res) {
|
51
|
+
console.log("[web] handleOnTap ", res);
|
52
|
+
this.$emit("onTap", res);
|
53
|
+
},
|
54
|
+
},
|
55
|
+
watch: {
|
56
|
+
loading(newText, oldText) {
|
57
|
+
if (newText !== oldText) {
|
58
|
+
this.scheduleTransfer(); // 当loading属性变化时重新调用
|
59
|
+
}
|
60
|
+
},
|
61
|
+
},
|
62
|
+
};
|
63
|
+
</script>
|
64
|
+
|
65
|
+
<style scoped>
|
66
|
+
</style>
|
@@ -0,0 +1,115 @@
|
|
1
|
+
<template>
|
2
|
+
<div>
|
3
|
+
<embed
|
4
|
+
:id="embedId"
|
5
|
+
type="native/button"
|
6
|
+
:width="width"
|
7
|
+
:height="height"
|
8
|
+
/>
|
9
|
+
</div>
|
10
|
+
</template>
|
11
|
+
|
12
|
+
<script>
|
13
|
+
const weexModule = weex.requireModule("weexModule");
|
14
|
+
|
15
|
+
export default {
|
16
|
+
name: "HlButton",
|
17
|
+
props: {
|
18
|
+
width: {
|
19
|
+
type: Number,
|
20
|
+
required: false,
|
21
|
+
default: 300,
|
22
|
+
},
|
23
|
+
height: {
|
24
|
+
type: Number,
|
25
|
+
required: false,
|
26
|
+
default: 120,
|
27
|
+
},
|
28
|
+
text: {
|
29
|
+
type: String,
|
30
|
+
required: false,
|
31
|
+
},
|
32
|
+
loading: {
|
33
|
+
type: Boolean,
|
34
|
+
require: true
|
35
|
+
},
|
36
|
+
stateEffect: {
|
37
|
+
type: Boolean,
|
38
|
+
require: true
|
39
|
+
}
|
40
|
+
},
|
41
|
+
data() {
|
42
|
+
return {
|
43
|
+
embedId: `richtext_${this._uid}`, // 使用Vue实例的唯一ID来生成embed元素的唯一ID
|
44
|
+
isTransferScheduled: false, // 添加一个标志来检查是否已经安排了transferPropsAndListeners的调用
|
45
|
+
};
|
46
|
+
},
|
47
|
+
destroyed() {
|
48
|
+
// TO-DO embed监听移除实现
|
49
|
+
},
|
50
|
+
created() {
|
51
|
+
console.log("[web] hl-button created!");
|
52
|
+
this.transferPropsAndListeners(); // 组件创建时调用
|
53
|
+
},
|
54
|
+
methods: {
|
55
|
+
transferPropsAndListeners() {
|
56
|
+
console.log("[web] transferPropsAndListeners ", this.onTap);
|
57
|
+
// 构建一个包含所需信息的对象
|
58
|
+
const args = {
|
59
|
+
componentId: this.embedId,
|
60
|
+
width: this.width,
|
61
|
+
height: this.height,
|
62
|
+
text: this.text,
|
63
|
+
loading:this.loading,
|
64
|
+
onTap: this.handleOnTap,
|
65
|
+
stateEffect: this.stateEffect
|
66
|
+
};
|
67
|
+
// 调用JSbridge方法,传递属性和监听方法到原生组件
|
68
|
+
native.transferSameLayerArgs(args);
|
69
|
+
},
|
70
|
+
scheduleTransfer() {
|
71
|
+
if (!this.isTransferScheduled) {
|
72
|
+
this.isTransferScheduled = true;
|
73
|
+
this.$nextTick(() => {
|
74
|
+
this.transferPropsAndListeners();
|
75
|
+
this.isTransferScheduled = false;
|
76
|
+
});
|
77
|
+
}
|
78
|
+
},
|
79
|
+
handleOnTap(res) {
|
80
|
+
console.log("[web] handleOnTap ", res);
|
81
|
+
this.$emit("onTap", res);
|
82
|
+
},
|
83
|
+
},
|
84
|
+
watch: {
|
85
|
+
text(newText, oldText) {
|
86
|
+
if (newText !== oldText) {
|
87
|
+
this.scheduleTransfer(); // 当text属性变化时重新调用
|
88
|
+
}
|
89
|
+
},
|
90
|
+
loading(newText, oldText) {
|
91
|
+
if (newText !== oldText) {
|
92
|
+
this.scheduleTransfer(); // 当loading属性变化时重新调用
|
93
|
+
}
|
94
|
+
},
|
95
|
+
width(newWidth, oldWidth) {
|
96
|
+
if (newWidth !== oldWidth) {
|
97
|
+
this.scheduleTransfer(); // 当width属性变化时重新调用
|
98
|
+
}
|
99
|
+
},
|
100
|
+
height(newHeight, oldHeight) {
|
101
|
+
if (newHeight !== oldHeight) {
|
102
|
+
this.scheduleTransfer(); // 当width属性变化时重新调用
|
103
|
+
}
|
104
|
+
},
|
105
|
+
stateEffect(newstateEffect, oldstateEffect) {
|
106
|
+
if (newstateEffect!== oldstateEffect){
|
107
|
+
this.scheduleTransfer(); // 当width属性变化时重新调用
|
108
|
+
}
|
109
|
+
}
|
110
|
+
},
|
111
|
+
};
|
112
|
+
</script>
|
113
|
+
|
114
|
+
<style scoped>
|
115
|
+
</style>
|
@@ -0,0 +1,53 @@
|
|
1
|
+
<template>
|
2
|
+
<BaseSameLayer
|
3
|
+
:hosSameLayerArgs="hosSameLayerArgs"
|
4
|
+
embedType="native/image"
|
5
|
+
:defaultWidth="300"
|
6
|
+
:defaultHeight="120"
|
7
|
+
></BaseSameLayer>
|
8
|
+
</template>
|
9
|
+
<script>
|
10
|
+
|
11
|
+
import BaseSameLayer from "./baseSameLayer.vue";
|
12
|
+
|
13
|
+
const weexModule = weex.requireModule('weexModule');
|
14
|
+
export default {
|
15
|
+
name: "HlImage",
|
16
|
+
components: {
|
17
|
+
BaseSameLayer,
|
18
|
+
},
|
19
|
+
props: {
|
20
|
+
src: {
|
21
|
+
type: String,
|
22
|
+
required: true,
|
23
|
+
},
|
24
|
+
hosUniqueProps:{
|
25
|
+
type: Object,
|
26
|
+
required: true,
|
27
|
+
},
|
28
|
+
},
|
29
|
+
methods: {
|
30
|
+
save(callback) {
|
31
|
+
console.log("testxxxxx", "image 组件 save 方法被触发")
|
32
|
+
weexModule.callNative('imageSaveHandle', {src: this.src,},callback)
|
33
|
+
},
|
34
|
+
handleLoad(res) {
|
35
|
+
this.$emit("load", res);
|
36
|
+
},
|
37
|
+
},
|
38
|
+
computed: {
|
39
|
+
hosSameLayerArgs() {
|
40
|
+
return {
|
41
|
+
...this.hosUniqueProps, // 鸿蒙原生组件独有属性
|
42
|
+
src: this.src,
|
43
|
+
handleLoad: this.handleLoad,
|
44
|
+
}
|
45
|
+
}
|
46
|
+
},
|
47
|
+
watch: {
|
48
|
+
},
|
49
|
+
};
|
50
|
+
</script>
|
51
|
+
|
52
|
+
<style scoped>
|
53
|
+
</style>
|
@@ -0,0 +1,151 @@
|
|
1
|
+
<template>
|
2
|
+
<div>
|
3
|
+
<embed
|
4
|
+
:id="embedId"
|
5
|
+
type="native/image"
|
6
|
+
:width="width"
|
7
|
+
:height="height"
|
8
|
+
:src="src"
|
9
|
+
/>
|
10
|
+
</div>
|
11
|
+
</template>
|
12
|
+
|
13
|
+
<script>
|
14
|
+
|
15
|
+
const weexModule = weex.requireModule('weexModule');
|
16
|
+
export default {
|
17
|
+
name: "HlImage",
|
18
|
+
props: {
|
19
|
+
src: {
|
20
|
+
type: String,
|
21
|
+
required: true,
|
22
|
+
},
|
23
|
+
resize: {
|
24
|
+
type: String,
|
25
|
+
default: "contain",
|
26
|
+
},
|
27
|
+
placeholder: {
|
28
|
+
type: String,
|
29
|
+
default: "images/loading.gif",
|
30
|
+
},
|
31
|
+
quality: {
|
32
|
+
type: String,
|
33
|
+
default: "original",
|
34
|
+
},
|
35
|
+
width: {
|
36
|
+
type: [Number, String],
|
37
|
+
default: 300,
|
38
|
+
},
|
39
|
+
height: {
|
40
|
+
type: [Number, String],
|
41
|
+
default: 120,
|
42
|
+
},
|
43
|
+
},
|
44
|
+
data() {
|
45
|
+
return {
|
46
|
+
embedId: `image_${this._uid}`, // 使用Vue实例的唯一ID来生成embed元素的唯一ID
|
47
|
+
isTransferScheduled: false, // 添加一个标志来检查是否已经安排了transferPropsAndListeners的调用
|
48
|
+
};
|
49
|
+
},
|
50
|
+
created() {
|
51
|
+
console.log("[weex] hl-image created!");
|
52
|
+
console.log("[weex] embed.width", this.width);
|
53
|
+
console.log("[weex] embed.height", this.height);
|
54
|
+
this.transferPropsAndListeners(); // 组件创建时调用
|
55
|
+
},
|
56
|
+
mounted() {
|
57
|
+
this.addTouchEvent();
|
58
|
+
},
|
59
|
+
beforeDestroy() {
|
60
|
+
this.removeTouchEvent();
|
61
|
+
},
|
62
|
+
methods: {
|
63
|
+
transferPropsAndListeners() {
|
64
|
+
// 构建一个包含所需信息的对象
|
65
|
+
const args = {
|
66
|
+
componentId: this.embedId,
|
67
|
+
width: this.width,
|
68
|
+
height: this.height,
|
69
|
+
src: this.src,
|
70
|
+
resize: this.resize,
|
71
|
+
placeholder: this.placeholder,
|
72
|
+
quality: this.quality,
|
73
|
+
handleLoad: this.handleLoad
|
74
|
+
};
|
75
|
+
// 调用JSbridge方法,传递属性和监听方法到原生组件
|
76
|
+
// @ts-ignore
|
77
|
+
// native.transferSameLayerArgs(args);
|
78
|
+
weexModule.callNative('transferSameLayerArgs', args)
|
79
|
+
},
|
80
|
+
// 必须给embed元素添加touchstart事件监听,addEventListener的第二个参数监听事件对象置空即可(同层渲染事件处理需要)
|
81
|
+
addTouchEvent() {
|
82
|
+
const embedElement = document.getElementById(this.embedId);
|
83
|
+
if (embedElement) {
|
84
|
+
console.log("[weex] hl-richtext-embed addEventListener");
|
85
|
+
embedElement.addEventListener('touchstart', {});
|
86
|
+
}
|
87
|
+
},
|
88
|
+
removeTouchEvent() {
|
89
|
+
const embedElement = document.getElementById(this.embedId);
|
90
|
+
if (embedElement) {
|
91
|
+
console.log("[weex] hl-richtext-embed removeEventListener");
|
92
|
+
embedElement.removeEventListener('touchstart', {});
|
93
|
+
}
|
94
|
+
},
|
95
|
+
scheduleTransfer() {
|
96
|
+
if (!this.isTransferScheduled) {
|
97
|
+
this.isTransferScheduled = true;
|
98
|
+
this.$nextTick(() => {
|
99
|
+
this.transferPropsAndListeners();
|
100
|
+
this.isTransferScheduled = false;
|
101
|
+
});
|
102
|
+
}
|
103
|
+
},
|
104
|
+
save(callback) {
|
105
|
+
console.log("testxxxxx", "image 组件 save 方法被触发")
|
106
|
+
weexModule.callNative('imageSaveHandle', {src: this.src,},callback)
|
107
|
+
},
|
108
|
+
handleLoad(res) {
|
109
|
+
this.$emit("load", res);
|
110
|
+
},
|
111
|
+
},
|
112
|
+
watch: {
|
113
|
+
// TO-DO 多个属性变化,待修改为一次性传递
|
114
|
+
src(newSrc, oldSrc) {
|
115
|
+
if (newSrc !== oldSrc) {
|
116
|
+
this.scheduleTransfer(); // 当src属性变化时重新调用
|
117
|
+
}
|
118
|
+
},
|
119
|
+
resize(newResize, oldResize) {
|
120
|
+
if (newResize !== oldResize) {
|
121
|
+
this.scheduleTransfer(); // 当resize属性变化时重新调用
|
122
|
+
}
|
123
|
+
},
|
124
|
+
placeholder(newPlaceholder, oldPlaceholder) {
|
125
|
+
if (newPlaceholder !== oldPlaceholder) {
|
126
|
+
this.scheduleTransfer(); // 当placeholder属性变化时重新调用
|
127
|
+
}
|
128
|
+
},
|
129
|
+
quality(newQuality, oldQuality) {
|
130
|
+
if (newQuality !== oldQuality) {
|
131
|
+
this.scheduleTransfer(); // 当quality属性变化时重新调用
|
132
|
+
}
|
133
|
+
},
|
134
|
+
"$attrs.width": {
|
135
|
+
immediate: true,
|
136
|
+
handler(newWidth) {
|
137
|
+
this.width = newWidth || 300; // 当父组件的宽度属性变化时,更新本地宽度值
|
138
|
+
},
|
139
|
+
},
|
140
|
+
"$attrs.height": {
|
141
|
+
immediate: true,
|
142
|
+
handler(newHeight) {
|
143
|
+
this.height = newHeight || 120; // 当父组件的高度属性变化时,更新本地高度值
|
144
|
+
},
|
145
|
+
},
|
146
|
+
},
|
147
|
+
};
|
148
|
+
</script>
|
149
|
+
|
150
|
+
<style scoped>
|
151
|
+
</style>
|