效果图:
代码:
例:
mui.init({
swipeBack: true, //启用右滑关闭功能
gestureConfig: {
hold: true, //默认为false,不监听
release: true //默认为false,不监听
}
});
mui.plusReady(function() {
mui('.mui-input-row textarea').input();
/*pickerdatetime();*/
document.querySelector("#msg-type").addEventListener("hold", function() {
this.classList.add('mui-active');
plus.speech.startRecognize({
engine: 'iFly',
onaudiostart: function() {}
}, function(text) {
text = text.toString().replace(/,/g, '').replace(/,。/g, '。').replace(/,!/g, '!').replace(/,?/g, '?');
var value = $("#msg-text").val();
$("#msg-text").val(value + text) ;
}, function(e) {
mui.toast("语音识别失败!");
}); //启动语音识别
});
document.querySelector("#msg-type").addEventListener("release", function() {
this.classList.remove('mui-active');
});
});
网友评论