12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- <!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">
- {{num}}
- </div>
- </div>
- `,
- data() {
- return{
- num:"abcd"
- }
- },
- methods: {
- box1Handle() {
- console.log('box1Handle')
- },
- box2Handle(){
- console.log('box2Handle')
- }
- }
- }
- }
- })
- </script>
- </body>
- </html>
|