将道具传递给Vue中的单文件组件

时间:2018-03-18 19:57:17

标签: javascript mvvm vue.js

我试图将现有应用中的数据传递到Vue中的单个文件组件。但是,该组件似乎没有从父母那里接收道具。

Sandbox here

代码:

// index.js
import Vue from "vue";
import App from "./App";

Vue.config.productionTip = false;

/* eslint-disable no-new */
new Vue({
  el: "#app",
  template: "<App/>",
  propsData: {
    someProp: "this is a prop test!!"
  },
  components: { App }
});

组件:

// App.js
<template>
    <div id="app">
        <h1>My Todo App! the prop: {{ someProp }}</h1>
        <TodoList/>
    </div>
</template>

<script>
import TodoList from "./components/TodoList.vue";

export default {
  props: ["someProp"],
  components: {
    TodoList
  }
};
</script>

结果根本没有显示道具,好像它没有传递任何东西。是什么给了什么?

0 个答案:

没有答案
相关问题