Difference between revisions of "Components"
Jump to navigation
Jump to search
(Created page with " ==Back To Top- Home - Category==") |
|||
Line 1: | Line 1: | ||
--user.vue | |||
<pre> | |||
<template> | |||
<div class="component"> | |||
<h1>The User Component</h1> | |||
<p>I'm an awesome User!</p> | |||
<button @click="changeName">Change my name</button> | |||
<hr> | |||
<div class="row"> | |||
<div class="col-xs-12 col-sm-6"> | |||
<app-user-detail :name="name"></app-user-detail> | |||
</div> | |||
<div class="col-xs-12 col-sm-6"> | |||
<app-user-edit></app-user-edit> | |||
</div> | |||
</div> | |||
</div> | |||
</template> | |||
<script> | |||
import UserDetail from "./UserDetail.vue"; | |||
import UserEdit from "./UserEdit.vue"; | |||
export default { | |||
data: function() { | |||
return { | |||
name: "Robert" | |||
}; | |||
}, | |||
methods: { | |||
changeName() { | |||
this.name = "Anna"; | |||
} | |||
}, | |||
components: { | |||
appUserDetail: UserDetail, | |||
appUserEdit: UserEdit | |||
} | |||
}; | |||
</script> | |||
</pre> | |||
==[[#top|Back To Top]]-[[Main_Page| Home]] - [[VueJs|Category]]== | ==[[#top|Back To Top]]-[[Main_Page| Home]] - [[VueJs|Category]]== |
Revision as of 23:38, 11 June 2018
--user.vue
<template> <div class="component"> <h1>The User Component</h1> <p>I'm an awesome User!</p> <button @click="changeName">Change my name</button> <hr> <div class="row"> <div class="col-xs-12 col-sm-6"> <app-user-detail :name="name"></app-user-detail> </div> <div class="col-xs-12 col-sm-6"> <app-user-edit></app-user-edit> </div> </div> </div> </template> <script> import UserDetail from "./UserDetail.vue"; import UserEdit from "./UserEdit.vue"; export default { data: function() { return { name: "Robert" }; }, methods: { changeName() { this.name = "Anna"; } }, components: { appUserDetail: UserDetail, appUserEdit: UserEdit } }; </script>