import HomeHeader from './components/header'
import HomeSwiper from './components/swiper'
import HomeIcons from './components/icons'
import HomeRecomment from './components/recomment'
import HomeGo from './components/go'
import Axios from 'axios'
import { mapState } from 'vuex'
export default {
name:"Home",
components:{HomeHeader,HomeSwiper,HomeIcons,HomeRecomment,HomeGo},
data (){
return {
swiperList:[],
iconList:[],
recommendList:[],
weekendList:[]
}
},
computed: {
...mapState(['city'])
},
methods:{
ajaxIndex () {
Axios.get('/api/index.json?city=' + this.city).then(this.respones)
},
respones (res) {
console.log(res);
const list=res.data.data;
this.city=list.city
this.swiperList=list.swiperList
this.iconList=list.iconList
this.recommendList=list.recommendList
this.weekendList=list.weekendList
}
},
mounted () {
this.lostcity = this.city
this.ajaxIndex()
},
activated () {
if (this.lostcity !== this.city) {
this.lostcity = this.city
this.ajaxIndex()
}
}
}报错:Computed property "city" was assigned to but it has no setter.
程序正常运行
课程紧跟Vue3版本迭代,企业主流版本Vue2+Vue3全掌握
了解课程