小程序开发中如何在第三方js中使用prototype进行this调用
如下代码,想请教如何像JS代码一样调用对应的方法,如this._connect();
JS代码如下:
function Client(host, i, pwd) { this.host = host || 'ws://localhost:80'; this._connect();}Client.prototype._connect = function() { console.log('test connect! ');};var c = new Client({ user: 'xiaoming', client_type: '1' }, '123456', false); |
小程序中utils加入 以进代码进行方法导出:
module.exports = {Client: Client,} |
遇到问题 Client方法中this._connect()错误,请问如何在小程序第三方引入的js中进行类使用?
