Skip to content

Instantly share code, notes, and snippets.

@earth774
Created March 18, 2019 12:57
Show Gist options
  • Save earth774/00a56aee6eb4b46423a164e1248dd466 to your computer and use it in GitHub Desktop.
Save earth774/00a56aee6eb4b46423a164e1248dd466 to your computer and use it in GitHub Desktop.
slot component
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Amiearth</title>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>
<body>
<div id="shop">
<food-app>
<h2>อาหารใต้</h2>
<ul>
<li>แกงเหลือง</li>
<li>แกงไตปลา</li>
</ul>
</food-app>
<food-app>
<h2>อาหารอีสาร</h2>
<ul>
<li>ลาบ</li>
<li>ส้มตำ</li>
</ul>
</food-app>
</div>
<template id="foodarea">
<div id="food">
<slot></slot>
</div>
</template>
<script>
var food = {
template: '#foodarea'
}
new Vue({
el: '#shop',
components: {
foodApp: food
}
})
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment