Skip to content

Commit

Permalink
📝 组件拆分
Browse files Browse the repository at this point in the history
  • Loading branch information
wuyongyu committed Sep 27, 2018
1 parent ce7c9f1 commit 2c17423
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,32 @@ <h1 v-text="content" @click="handleClick"></h1>
<button @click="handleInput">提交</button>
</div>
<ul>
<li v-for="(item, index) of inputList" :key="index">{{item}}</li>
<todo-item
v-for="(item, index) of inputList"
:key="index"
:content="item"
></todo-item>
</ul>
</div>

<script>

// 全局组件
Vue.component("todo-item", {
props: ['content'],
template: "<li>{{content}}</li>"
});

// 局部组件
// var TodoItem = {
// template: "<li>item</li>"
// };

new Vue({
el: "#root",
// component: {
// "todo-item": TodoItem
// },
data: {
content: "hello",
title: "this is Vue",
Expand Down

0 comments on commit 2c17423

Please sign in to comment.