zheng 4 dni temu
rodzic
commit
3832f3cf97
2 zmienionych plików z 93 dodań i 0 usunięć
  1. 39 0
      vue/初阶/18.组件.html
  2. 54 0
      vue/初阶/19.嵌套组件.html

+ 39 - 0
vue/初阶/18.组件.html

@@ -0,0 +1,39 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>Document</title>
+</head>
+<body>
+    <div id="app">
+        <my-com></my-com>
+        <hi></hi>
+    </div>
+    <script src="./vue.js"></script>
+    <script>
+       Vue.component("my-com",{
+        template: `<h1>你好</h1>`
+       })
+    const news = Vue.extend({
+         template: `<ul>
+                <li>111</li>
+                <li>222</li>
+3                <li>333</li>
+            </ul>`
+    })
+        var app = new Vue({
+            el:"#app",
+            data:{
+            },
+            components:{
+                hi:news
+            }
+        })
+        /**
+         * 全局组件
+         * 局部组件
+        */
+    </script>
+</body>
+</html>

+ 54 - 0
vue/初阶/19.嵌套组件.html

@@ -0,0 +1,54 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>Document</title>
+</head>
+
+<body>
+    <div id="app">
+        <news></news>
+    </div>
+    <script src="./vue.js"></script>
+    <script>
+
+        const hi = Vue.extend({
+            name:'hi',
+            template: `<h1>你好</h1>{{names}}`,
+            data() {
+                return {
+                    names: "图图"
+                }
+            }
+        })
+        
+        const news = Vue.extend({
+            name:'news',
+            template: `
+          <div>
+                <hi></hi>
+                <ul>
+                    <li>111</li>
+                    <li>222</li>
+                    <li>333</li>
+                </ul>
+            </div>`,
+            components: {
+                hi
+            }
+        })
+
+        var app = new Vue({
+            el: "#app",
+            data: {
+            },
+            components: {
+                news
+            }
+        })
+    </script>
+</body>
+
+</html>