SOURCE

console 命令行工具 X clear

                    
>
console
<!DOCTYPE html>
<html lang="en">

<head>
    <title>Mixins Option 混入</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <script type="text/javascript" src="../assets/js/vue.js"></script>
</head>

<body>
    <h1>Mixins Option 混入</h1>
    <hr>
    <div id="app">
        <p>num:{{ num }}</p>
        <P><button @click="add">增加数量</button></P>
    </div>

    <script type="text/javascript">
        //额外临时加入时,用于显示日志
        var addConsole = {
            updated: function () {
                alert("数据放生变化,变化成" + this.num + ".");
            }
        }

        Vue.mixin({
            updated() {
                alert("我是全局的混入的Update");
            },
        })

        var app = new Vue({
            el: '#app',
            data: {
                num: 1
            },
            methods: {
                add: function () {
                    this.num++;
                }
            },
            updated: function () {
                alert("我是原生的Update");
            },
            mixins: [addConsole] //混入
        })
    </script>
</body>

</html>

本项目引用的自定义外部资源