App.vue 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <template>
  2. <div id="app">
  3. <!-- <NavigationLink url="/profile"> 个人信息 </NavigationLink>
  4. <NavigationLink url="/profile">
  5. <span :style="{ color: 'red' }">个人信息</span>
  6. </NavigationLink>
  7. <NavigationLink url="/profile"> -->
  8. <!-- 组件渲染时 内容区域的作用域 是在其 父组件 内-->
  9. <!-- <span :style="{ color }">个人信息</span>
  10. </NavigationLink> -->
  11. <!-- <div>
  12. <h3>默认插槽</h3> -->
  13. <!-- 下面 由于在渲染组件时没有指定插槽内容,那么就会使用默认值 -->
  14. <!-- <MyButton /> -->
  15. <!-- 如果 指定了,就替换掉 默认值 -->
  16. <!-- <my-button>保存</my-button>
  17. </div>-->
  18. <MyContainer>
  19. <template v-slot:header>
  20. <div :style="{ height: '100%', lineHeight: '50px' }">XXX管理系统</div>
  21. </template>
  22. <template v-slot:aside>
  23. <ul>
  24. <li>主页</li>
  25. <li>用户管理</li>
  26. <li>商品管理</li>
  27. </ul>
  28. </template>
  29. <template v-slot:main>
  30. <p>欢迎使用 XXX 管理系统!</p>
  31. <current-user>
  32. <!-- v-slot指令的绑定值 是固定slot所绑定的所有属性,即一个对象 通常我们命名为 slotProps -->
  33. <template v-slot:default="slotProps">
  34. <p>
  35. {{ slotProps.user.firstName }} - {{ slotProps.user.lastName }}
  36. </p>
  37. </template>
  38. </current-user>
  39. <current-user>
  40. <!-- v-slot指令的绑定值 是固定slot所绑定的所有属性,即一个对象 通常我们命名为 slotProps -->
  41. <!-- slotProps 是一个 对象 ,v-slot指令 是可以在绑定值中使用解构语法 -->
  42. <template v-slot:default="{ user }">
  43. <p>当前用户:{{ user.firstName }} {{ user.lastName }}</p>
  44. </template>
  45. </current-user>
  46. <current-user>
  47. <!-- v-slot指令的绑定值 是固定slot所绑定的所有属性,即一个对象 通常我们命名为 slotProps -->
  48. <!-- slotProps 是一个 对象 ,v-slot指令 是可以在绑定值中使用解构语法 -->
  49. <!-- 如果 插槽的名字 为 default 那么是有简写的方式。即可以省略:default -->
  50. <template v-slot="{ user }">
  51. <p>当前用户:{{ user.firstName }} - {{ user.lastName }}</p>
  52. </template>
  53. </current-user>
  54. </template>
  55. </MyContainer>
  56. </div>
  57. </template>
  58. <script>
  59. import CurrentUser from './components/CurrentUser.vue';
  60. // import MyButton from './components/MyButton.vue';
  61. // import NavigationLink from './components/NavigationLink.vue';
  62. export default {
  63. components: { CurrentUser },
  64. name: 'App',
  65. data() {
  66. return {
  67. color: 'hotpink',
  68. };
  69. },
  70. // components: { NavigationLink, MyButton },
  71. };
  72. </script>
  73. <style>
  74. body {
  75. margin: 0;
  76. padding: 0;
  77. }
  78. #app {
  79. font-family: Avenir, Helvetica, Arial, sans-serif;
  80. -webkit-font-smoothing: antialiased;
  81. -moz-osx-font-smoothing: grayscale;
  82. text-align: center;
  83. color: #2c3e50;
  84. /* margin-top: 60px; */
  85. }
  86. </style>