【发布时间】:2017-02-27 08:47:05
【问题描述】:
如何将数据从 Vue 实例传递到 Vue 组件?我正在尝试对驻留在我的组件模板中的“li”执行“v-for”,这是fiddle
HTML
<div id="app">
<my-notification></my-notification>
</div>
<template id="my-template">
<ul>
<li v-for="nn in notifications">{{ nn }}</li>
</ul>
</template>
Vue 脚本
Vue.component('my-notification',{
template : '#my-template',
});
new Vue({
el : '#app',
data : {
notifications : ['notification 1','notification 2','notification 3']
}
});
不幸的是,到目前为止我尝试了什么(见我的小提琴)都不起作用,请帮忙?
【问题讨论】:
标签: javascript vue.js vue-component