一 項目結構css
二 App組件vue
<template> <div id="app"> <fruit/> </div> </template> <script> import "./components/Fruit.js"; export default { name: "App" }; </script> <style lang="scss"> </style>
三 Fruit組件app
import Vue from "vue"; import Mongo from "./Mongo.vue"; Vue.component("fruit", { data() { return { kind: "大青芒", address: "雲南" }; }, render() { const { kind, address } = this; return ( <Mongo kind={kind} address={address}> very delicious </Mongo> ); } });
四 芒果組件ui
<template> <div> <h2>芒果</h2> <slot/> <h6>{{kind}},{{address}}</h6> </div> </template> <script> export default { name: "Mango", props: ["kind", "address"] }; </script>
五 運行效果this