export default {
data() {
return {
jssip:{}
};
},
created() {
let webSocketInterface = new WebSocketInterface("ws://127.0.0.1:5066");
let configuration = {
sockets: [webSocketInterface],
uri: 'sip:1001@127.0.0.1',
password: 11111,
register: false
};
this.jssip = new UA(configuration);
this.jssip.start()
this.jssip.on('connected', () => {
this.jssip.register()
})
},
};
如果代码是上面例子那样写的话就会出现'get' on proxy: property 'uri' is a read-only and non-configurable data property on the proxy target but the proxy did not return its actual value (expected '[object Object]' but got '[object Object]') 这样的报错。
原因是vue是响应式的,会将data()里定义的变量加上Proxy。
解决方式就是定义window.jssip变量就行了