代码之家  ›  专栏  ›  技术社区  ›  Marcus Aurelio

尝试使用道具将数据传递给全局对象,但无法获取要显示的数据

  •  1
  • Marcus Aurelio  · 技术社区  · 6 年前

    let store = {
      _author: 'Johnnie Walker',
    };
    
    Vue.component('post', {
      template: '#post-template',
      props: ['title', 'author', 'content']
    });
    
    var vm = new Vue({
      el: '#app',
      data: {
        author: store,
        title: 'Aging Your Own Whisky',
        content: 'A bunch of steps and a whole lot of content'
      }
    });
    

    https://jsfiddle.net/syed263/yk8L1tru/1/

    1 回复  |  直到 6 年前
        1
  •  3
  •   Rishikesh Dhokare    6 年前

    store _author 在里面。

    你的 data 应该是-

    data: {
      author: store._author,
      title: 'Aging Your Own Whisky',
      content: 'A bunch of steps and a whole lot of content'
    }