get_collect(obj) { var user_id = this.user.user_id; var query = { source_table: "dish_information", source_field: "dish_information_id", source_id: obj["dish_information_id"], user_id }; this.$get('~/api/collect/count?', query, (res) => { console.log(res); if (res.result || res.result === 0) { var bl = res.result ? true : false; this.state_collect = bl; console.log("收藏状态:" + bl); } else if(res.error) { console.error(res.error); } }); },
时间: 2023-12-06 15:42:35 浏览: 32
这是一个 JavaScript 函数,用于获取用户是否已经收藏了某个菜品信息。函数接受一个参数 obj,该参数包含菜品信息的 id 属性(dish_information_id)。函数首先获取当前用户的 id(user_id),然后构建一个查询对象,包含 source_table、source_field、source_id 和 user_id 属性。接下来,函数通过调用 $get 方法,向服务器发起一个 GET 请求,查询该菜品信息的收藏状态。如果请求成功,函数会将收藏状态保存在 state_collect 变量中,并向控制台输出收藏状态。如果请求失败,函数会向控制台输出错误信息。
相关问题
time="2023-06-07T22:01:46+08:00" level=info msg="Starting mysqld_exporter (version=0.12.1, branch=HEAD, revision=48667bf7c3b438b5e93b259f3d17b70a7c9aff96)" source="mysqld_exporter.go:257" time="2023-06-07T22:01:46+08:00" level=info msg="Build context (go=go1.12.7, user=root@0b3e56a7bc0a, date=20190729-12:35:58)" source="mysqld_exporter.go:258" time="2023-06-07T22:01:46+08:00" level=info msg="Enabled scrapers:" source="mysqld_exporter.go:269" time="2023-06-07T22:01:46+08:00" level=info msg=" --collect.global_status" source="mysqld_exporter.go:273" time="2023-06-07T22:01:46+08:00" level=info msg=" --collect.global_variables" source="mysqld_exporter.go:273" time="2023-06-07T22:01:46+08:00" level=info msg=" --collect.slave_status" source="mysqld_exporter.go:273" time="2023-06-07T22:01:46+08:00" level=info msg=" --collect.info_schema.innodb_cmp" source="mysqld_exporter.go:273" time="2023-06-07T22:01:46+08:00" level=info msg=" --collect.info_schema.innodb_cmpmem" source="mysqld_exporter.go:273" time="2023-06-07T22:01:46+08:00" level=info msg=" --collect.info_schema.query_response_time" source="mysqld_exporter.go:273" time="2023-06-07T22:01:46+08:00" level=info msg="Listening on :9104" source="mysqld_exporter.go:283"
这是 mysqld_exporter 启动时的日志信息,其中包含了一些重要的信息:
1. mysqld_exporter 的版本、分支和代码版本号等信息。
2. 启用的采集器(scrapers)列表,包括 `global_status`、`global_variables`、`slave_status`、`info_schema.innodb_cmp`、`info_schema.innodb_cmpmem`、`info_schema.query_response_time` 等。
3. 监听的端口号,默认为 9104。
根据日志信息可以得知 mysqld_exporter 已经成功启动,并且正在监听端口号 9104,可以通过访问 `http://localhost:9104/metrics` 查看 MySQL 相关指标。
data(){ return{ url_get_obj: "~/api/dish_information/get_obj?", field: "dish_information_id", obj: { "praise_len": 0, }, query: { "dish_no": "", "type_of_dish": "", "name_of_dish": "", "price_of_dishes": "", "picture_of_dishes": "", "introduction_details": "", "dish_information_id":0, }, // 点赞 praise: 0, // 点赞状态 state_praise: false, // 收藏状态 state_collect: false, list_comment: [], form_comment: { source_table: "dish_information", source_field: "dish_information_id", source_id: 0, reply_to_id: 0, }, count_pages: 1, // 页面数 } },
这是一个Vue.js组件的data部分。
- `url_get_obj` 是一个API接口的URL,用于获取菜品信息。
- `field` 是作为查询参数的字段名,用于查询菜品信息。
- `obj` 是一个对象,表示菜品信息,其中 `praise_len` 表示点赞数。
- `query` 是一个对象,表示查询参数,包括菜品编号、类型、名称、价格、图片和介绍等信息。
- `praise` 表示点赞数。
- `state_praise` 表示点赞状态,初始值为false。
- `state_collect` 表示收藏状态,初始值为false。
- `list_comment` 是一个数组,表示评论列表。
- `form_comment` 是一个对象,表示评论表单,包括评论的来源表、来源字段、来源ID和回复ID等信息。
- `count_pages` 表示页面数,初始值为1。
相关推荐
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)