Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
600 views
in Technique[技术] by (71.8m points)

vue data赋值赋不上去

export default {
  name: 'SidebarMenu',
  props: {item: {}},
  data () {
    return {
      menuList: [{}]
    }
  },
  created: function () {
    this.getMenuList()
  },
  methods: {

    getMenuList (event) {
      $.getJSON('/cost-manager/sys/menu/user?_' + $.now(), function (r) {
        // console.log(r)
        this.menuList = r.menuList

      })
    }
  }
}


*
menuList始终为空,赋值赋不上去,求解

*


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

在getjson外声明 var _self = this; _self.menuList = r.menu.List;


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...