From 2e93f1465fab7aa1c83248fd159532f193da9525 Mon Sep 17 00:00:00 2001 From: aixianling Date: Wed, 8 Jan 2025 15:18:37 +0800 Subject: [PATCH] =?UTF-8?q?refactor(xumu):=20=E9=87=8D=E6=9E=84=E8=80=B3?= =?UTF-8?q?=E6=A0=87=E9=80=89=E6=8B=A9=E5=99=A8=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增计算属性 api,用于生成请求 URL - 将 watch 目标从 action 改为 api - 优化 getEartag 方法,使用计算属性 api 替代手动构建 URL --- project/xumu/components/AiEartagPicker.vue | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/project/xumu/components/AiEartagPicker.vue b/project/xumu/components/AiEartagPicker.vue index 0b86ec76..faf2e86f 100644 --- a/project/xumu/components/AiEartagPicker.vue +++ b/project/xumu/components/AiEartagPicker.vue @@ -18,8 +18,17 @@ export default { selected: [] } }, + computed: { + api: v => { + let url = v.action + if (v.penId) { + url += `?penId=${v.penId}` + } + return url + } + }, watch: { - action: { + api: { immediate: true, handler() { this.getEartag() @@ -28,11 +37,7 @@ export default { }, methods: { getEartag() { - let url = this.action - if (this.penId) { - url += `?penId=${this.penId}` - } - !/undefined/.test(url) && this.instance.post(url).then(res => { + !/undefined/.test(this.api) && this.instance.post(this.api).then(res => { if (res?.data) { this.list = res.data }