From 7cdf310aa91e63147323c2a2f9f37477ec4f9e57 Mon Sep 17 00:00:00 2001 From: hzj <1304805162@qq.com> Date: Wed, 28 Jan 2026 18:33:40 +0800 Subject: [PATCH] =?UTF-8?q?feat(banner=E7=AE=A1=E7=90=86=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?):=20=E6=90=9C=E7=B4=A2=E6=A0=8F=E2=80=9C=E5=9B=BD=E5=AE=B6?= =?UTF-8?q?=E2=80=9D=E9=80=89=E9=A1=B9=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/sys/banner/index.vue | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/views/sys/banner/index.vue b/src/views/sys/banner/index.vue index 21cbdf2..0a8d7be 100644 --- a/src/views/sys/banner/index.vue +++ b/src/views/sys/banner/index.vue @@ -310,7 +310,7 @@ export default { textOptTitle: "", listLoading: true, - selectedCountry: {}, + selectedCountry: {}, // 存储完整的国家对象 countryList: [], loadingCountry: false }; @@ -381,10 +381,21 @@ export default { const that = this; console.log("val", val); - that.selectedCountry = this.countryList.filter( - item => item.country.alphaTwo === val - )[0]; - that.listQuery.countryCode = this.selectedCountry.country.alphaTwo; + if (!val) { + // 如果没有选择国家,清空相关字段 + that.listQuery.countryCode = ""; + that.selectedCountry = {}; + } else { + // 选择了一个国家 + that.selectedCountry = + this.countryList.find(item => item.country.alphaTwo === val) || {}; + + // 使用传统的方式访问嵌套属性 + that.listQuery.countryCode = that.selectedCountry.country + ? that.selectedCountry.country.alphaTwo + : ""; + } + this.renderData(); }, @@ -397,7 +408,8 @@ export default { .then(res => { that.loadingCountry = false; that.countryList = res.body || []; - that.listQuery.countryCode = that.selectedCountry.country.alphaTwo; + that.listQuery.countryCode = ""; + that.selectedCountry = {}; // that.renderData(); }) .catch(er => {