/
extend-in-anotherjs.js
55 lines (55 loc) · 1.28 KB
/
extend-in-anotherjs.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import SifoSingleton from '@schema-plugin-flow/sifo-singleton';
import { message } from 'ant-design-vue';
// 扩展组件(局部)
const components = {
'test-ext-button': {
data: function () {
return {
count: 0
}
},
template: `
<button v-bind:style="{ margin: '0 8px' }" v-on:click="count++">
You clicked me {{ count }} times.
</button>`
}
};
const componentPlugin = {
btn_change_id: {
onComponentInitial: params => {
const { event, mApi } = params;
setTimeout(() => {
message.info("外部扩展:点击按钮3次将日期组件改为扩展组件", 3);
mApi.setAttributes(event.key, {
size: "large",
style: {
color: 'red'
}
});
}, 2000);
let count = 0;
mApi.addEventListener(event.key, 'click', () => {
count++;
if (count >= 3) {
mApi.replaceComponent('date', 'test-ext-button');
}
});
}
}
};
// 按namespace注册
const singleton = new SifoSingleton('complex-sifo-demo');
singleton.registerItem('extendId01', () => {
console.log('singleton');
return {
version: '1.0.0',
plugins: [
{
componentPlugin,
pagePlugin: {}
}
],
components,
openLogger: true
}
});