methods:{
// 创建电话组件
createCallComponent(phoneNum) {
if (window.callComp && !window.callComp.isDestroyed) {
return;
};
window.callComp = new UdeskCallcenterComponent({
container: document.body,
token: this.agentToken,
subDomain: this.subDomain,
showManualScreenPop: false,
onHangup: function(conversation) { // 电话挂断时执行
getCallId(conversation.call_id); // 这里调用绑定后的方法,并传入callid
window.callComp.destroy(); // 销毁电话组件
window.callComp = null; // 销毁电话组件</
Vue丨将组件 methods 内的方法绑定到 window 来调用
最新推荐文章于 2024-08-23 09:37:58 发布
在Vue项目中,由于作用域和异步执行的问题,导致组件内的methods方法无法在第三方组件中或外部正确执行。通过将methods中的方法绑定到window对象,确保了在第三方组件完成时能够正确调用,从而解决了执行顺序问题。欢迎分享不同的解决方案进行交流学习。
摘要由CSDN通过智能技术生成