后端向前端传数据,前端可以得到数据,但是无法将得到的数据赋值到menuList1和menuList2中怎么解决?
export default {
data() {
return {
// 左侧菜单数据
// 一级菜单
menuList1: [],
// 二级菜单
menuList2: [],
}
},
// 定义生命周期函数
created() {
this.getMeunList()
},
methods: {
logout() {
window.sessionStorage.clear()
this.$router.push('/login')
},
// 获得所有的左侧菜单
async getMeunList() {
const res = await this.$http.get(this.hd+'/selectList1')
const { data: res1 } = await this.$http.get(this.hd + '/selectList1')
const { data: res2 } = await this.$http.get(this.hd + '/selectList2')
console.log(res)
console.log(res1)
console.log(res2)
this.menuList1 = res1.list
console.log("一级菜单"+this.menuList1)
this.$set.menuList2 = res2.list
console.log("二级菜单"+this.menuList2)
},
},
}