主页点击哪个城市,显示哪个城市的数据
import { mapState } from "vuex";
导入mapState
computed: { ...mapState(["cityName"]), },
循环请求到的数据,判断是否点击的文字和请求到的数据是否一样
methods: { http() { let that = this; this.axios.get("http://localhost:8080/api/dataHome.json").then((res) => { // console.log(res.data.data); let data = res.data.data; data.forEach((item) => { if (that.cityName == item.city) { console.log(item); that.spikeList = item.spikeList; that.likeList = item.likeList; } }); }); }, },

浙公网安备 33010602011771号