Vue组件方法:页面滚动和敏感词检测
这段代码是一个Vue组件中的方法,其中包含了两个函数:'setPageScrollTo'和'checkmsg'。'setPageScrollTo'函数用于设置页面滚动到指定位置,根据当前消息列表的长度来设置滚动位置。'checkmsg'函数用于检查用户输入的消息是否包含敏感词,如果包含敏感词则提示用户修改后再发送,否则调用'sendmsg'函数发送消息。其中使用了一个第三方库'common_vendor'来发送请求。
setPageScrollTo() {
let len = this.msgList.length;
this.scrollInto = 'id' + (len - 1);
},
checkmsg() {
this.show = false;
this.msgLoad == true;
let data = JSON.stringify({
msg: this.msg,
openid: this.openid
});
common_vendor.index.request({
url: this.apiurl + '/wordcheck',
data,
method: 'POST',
timeout: 3e5,
success: (res) => {
console.log(res);
if (res.data.code != 1) {
this.toast('内容包含敏感词,请修改后再使用!');
return;
} else {
this.sendmsg();
}
}
});
},
原文地址: https://www.cveoy.top/t/topic/lR56 著作权归作者所有。请勿转载和采集!