|
@@ -0,0 +1,93 @@
|
|
|
+<!DOCTYPE html>
|
|
|
+<html lang="en">
|
|
|
+
|
|
|
+<head>
|
|
|
+ <meta charset="UTF-8">
|
|
|
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
+ <title>Document</title>
|
|
|
+ <script src="./js/vue.js"></script>
|
|
|
+ <style>
|
|
|
+ .box {
|
|
|
+ width: 100px;
|
|
|
+ height: 100px;
|
|
|
+ background-color: red;
|
|
|
+ margin: 10px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .box2 {
|
|
|
+ width: 100px;
|
|
|
+ height: 100px;
|
|
|
+ background-color: blue;
|
|
|
+ margin: 10px;
|
|
|
+ }
|
|
|
+ </style>
|
|
|
+</head>
|
|
|
+
|
|
|
+<body>
|
|
|
+ <div id="app">
|
|
|
+ <list-content></list-content>
|
|
|
+ <box></box>
|
|
|
+ <button @click="appHandle">button</button>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <template id="box-temp">
|
|
|
+ <div class="container">
|
|
|
+ <div @click="box1Handle" class="box">
|
|
|
+ <span>hello world</span>
|
|
|
+ </div>
|
|
|
+ <div @click="box2Handle" class="box2">
|
|
|
+ {{num}}
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+
|
|
|
+ <template id="list-content">
|
|
|
+ <div class="container">
|
|
|
+ <ul>
|
|
|
+ <li>1</li>
|
|
|
+ <li>2</li>
|
|
|
+ <li>3</li>
|
|
|
+ <li>4</li>
|
|
|
+ <li>5</li>
|
|
|
+ </ul>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+
|
|
|
+ <script>
|
|
|
+ let app = new Vue({
|
|
|
+ el: '#app',
|
|
|
+ data: {
|
|
|
+
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ appHandle() {
|
|
|
+ console.log('appHandle')
|
|
|
+ }
|
|
|
+ },
|
|
|
+ components: {
|
|
|
+ listContent:{
|
|
|
+ template:"#list-content",
|
|
|
+ },
|
|
|
+ box: {
|
|
|
+ template: "#box-temp",
|
|
|
+ // 组件内部的data是个函数 内部返回一个对象
|
|
|
+ data() {
|
|
|
+ return{
|
|
|
+ num:"abcd"
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ box1Handle() {
|
|
|
+ console.log('box1Handle')
|
|
|
+ },
|
|
|
+ box2Handle(){
|
|
|
+ console.log('box2Handle')
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ </script>
|
|
|
+</body>
|
|
|
+
|
|
|
+</html>
|