123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- <!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">
- <box></box>
- <button @click="appHandle">button</button>
- </div>
- <script>
- let app = new Vue({
- el: '#app',
- data: {
- },
- methods: {
- appHandle() {
- console.log('appHandle')
- }
- },
- components: {
- box: {
- template: `
- <div class="container">
- <div @click="box1Handle" class="box">
- <span>hello world</span>
- </div>
- <div @click="box2Handle" class="box2"></div>
- </div>
- `,
- methods: {
- box1Handle() {
- console.log('box1Handle')
- },
- box2Handle(){
- console.log('box2Handle')
- }
- }
- }
- }
- })
- </script>
- </body>
- </html>
|