• vue里的共享对象示例


    <!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="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    </head>
    <body>
        <div id="app">
            <my-component></my-component>
            <my-component></my-component>
        </div>
        <script>

            var data1={
                counter:0
            }
            Vue.component("my-component",{
                template:"<button @click='count'>点击事件{{counter}}</button>",
                data:function(){
                    //return 处的对象引用了外部对象,那么这个对象就是共享对象
                    return data1
                },
                methods:{
                    count:function(){
                        data1.counter++;
                    }
                }
            }
            );
            var v=new Vue({
                el:"#app"
            });
          
        </script>
    </body>
    </html>
  • 相关阅读:
    servlet的提交
    servlet的doPost 和doGet和web文件结构
    helloServlet
    捕鱼达人
    The 2018 ACM-ICPC China JiangSu Provincial Programming Contest I. T-shirt
    ACM-ICPC 2017 Asia Urumqi A. Coins
    Nordic Collegiate Programming Contest 2015​ B. Bell Ringing
    变量
    hiho 1050 树的直径
    ACM-ICPC 2017 Asia Urumqi G. The Mountain
  • 原文地址:https://www.cnblogs.com/kukai/p/12906923.html
Copyright © 2020-2023  润新知