1描述问题:
我现在想实现的是左边菜单栏,点击其中的主菜单会出现几个二级菜单。主菜单会有几个。后台传递的json数据是数组,数据内部的成员是对象,对象还是数组,类似这样的结构:
我现在想渲染在左边菜单栏中。
2我的代码:
js代码:
var Child = Vue.extend({
props:['didi'],
template: '#menuUlLi',
data:function(){
return{
didi:this.didi
}
}
})
var bar = new Vue({
el:'#app',
data:{
liiterms:[]
},
components:{
myItem:Child
},
created:function(){
this.setmenu();
},
methods:{
setmenu:function(){
this.$http({url:'leftDir/getDirTree',
params:{
token:cookie.get("token")
},
headers:{Authorization:'Basic Yxsdlfjui'}})
.then(function(response){
console.log(response.data.body);
if(response.data.code=="0001"){
this.liiterms = response.data.body;
}
},function(){
})
}
}
});
3报错信息:
不知道是什么问题造成的?本人初学vue,希望大神指点。
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
v-if是指令,直接写JS变量就好; $index在2.0中已经移除了。