如果this.remarkData.remark前后去空格后,仍然为空值,则返回false
时间: 2024-03-23 07:38:26 浏览: 12
好的,你的第一个问题是关于JavaScript代码的。根据你的描述,我可以给你一个示例代码,供你参考:
```javascript
if(this.remarkData && this.remarkData.remark && this.remarkData.remark.trim() !== '') {
return true;
} else {
return false;
}
```
这段代码首先判断 `this.remarkData` 是否存在,如果存在,则继续判断 `this.remarkData.remark` 是否存在。如果 `this.remarkData.remark` 存在,则使用 `trim()` 方法去掉前后空格。如果去掉前后空格后,仍然不为空值,则返回 `true`,否则返回 `false`。
相关问题
addRemark( { "star": this.form.star, "remark": this.form.remark, "acceptId": aid, "publishId": pid, "taskId": taskid, }).then(response => { this.$message("新增成功"); this.open = false; });
这段代码是一个前端调用后端接口的异步请求,使用了axios库,向后端发送一个POST请求,请求参数为一个对象,包含star、remark、acceptId、publishId、taskId这五个属性值。请求成功后,会弹出一个提示框,显示“新增成功”,并将表单关闭。
具体而言,该请求的作用是向后端新增一条评价信息,其中:
- star:表示评价的星级,类型为数字;
- remark:表示评价的内容,类型为字符串;
- acceptId:表示接受任务的用户ID,类型为数字;
- publishId:表示发布任务的用户ID,类型为数字;
- taskId:表示任务的ID,类型为数字。
this.$Axios.post提交表单
this.$Axios.post提交表单是指使用Axios库中的post方法来提交表单数据。在引用\[2\]和引用\[3\]中都提到了使用Axios库的post方法来发送POST请求。具体的使用方法是通过调用this.$axios.post(url, data)来发送POST请求,其中url是请求的地址,data是要发送的表单数据。在引用\[2\]中的代码示例中,使用了this.axios.post("user_login.php", data)来提交表单数据。而在引用\[3\]中的代码示例中,使用了this.$axios.post('/user/login', this.$qs.stringify({ login_account: this.loginForm.username, password: this.loginForm.password, remark: this.checked === true ? 'autologin' : 'nocheck' }))来提交表单数据。所以,this.$Axios.post提交表单的具体实现可以参考这两个代码示例。
#### 引用[.reference_title]
- *1* *2* [vue项目分析--this.$store.dispatch()&this.$store.commit()&vuex.store()](https://blog.csdn.net/weixin_46045444/article/details/120720528)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item]
- *3* [axios发送post请求,提交表单数据](https://blog.csdn.net/weixin_30670925/article/details/98508087)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]