Skip to content

Commit

Permalink
fix: 在vue自定义组件中暴露amis事件动作
Browse files Browse the repository at this point in the history
  • Loading branch information
wibetter committed Feb 16, 2023
1 parent 6d0bbbd commit 65c6e8f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -96,7 +96,7 @@
"url": "https://github.com/aisuda/multiple-custom-widget-template/issues"
},
"dependencies": {
"amis-widget": "^3.0.8",
"amis-widget": "^3.0.9",
"jquery": "^3.5.1",
"react": "^16.8.6",
"vue": "^2.6.14"
Expand Down
21 changes: 18 additions & 3 deletions src/vue-widget/info-card.vue
Expand Up @@ -19,9 +19,6 @@
</div>
</template>
<script>
/**
* 视频模板页
*/
export default {
props: {
title: {
Expand Down Expand Up @@ -67,6 +64,24 @@ export default {
return `${Math.floor(agreeData / 1000) / 10}w`;
}
},
/**
* 添加amis事件动作:
* 在这里设置自定义组件对外暴露的动作,其他组件可以通过组件动作触发自定义组件的对应动作
*/
doAction(action, args) {
const actionType = action ? action.actionType : '';
if (actionType === 'message') {
// 接收外部组件的事件动作'message'
alert('您触发了自定义组件的事件动作[message]');
} else {
console.log(
'自定义组件中监听到的事件动作:',
action,
', 事件参数:',
args,
);
}
},
},
};
</script>
Expand Down

0 comments on commit 65c6e8f

Please sign in to comment.