vue学习1 v-bind v-on computed watch

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <title>Title</title>

    <style>

    </style>

    <script src="https://cdn.bootcss.com/vue/2.6.10/vue.min.js"></script>

</head>

<body>

    <div id="app">

        {{msg}}

        <div v-html="template">

        </div>

        <a v-bind:href="url">百度</a>

        {{count}}

        <button type="button" v-on:click="submit()">加数字</button>

        <div v-bind:id="bg1">

            hello world!

        </div>

        <p>

            {{msg1}}

        </p>

    </div>

    <!--

        v-bind == :绑定 属性

        v-on == @  :监听

        computed 计算属性

        watch 侦听器

        v-if    -->

</body>

<script>

    var app1 = 'this is app1!';

    var app = new Vue({

        el: '#app',

        data: {

            msg: 'hello vue!',

            another: 'another vue!!',

            count: 0,

            template: '<div>hello template</div>',

            url: 'http://www.baidu.com',

            bg1: 'app-bind'

        },

        watch: {

            msg: function (newval, oldval) {

                console.log('newval is:' + newval);

                console.log('oldval is:' + oldval);

            }

        },

        computed: {

            msg1: function () {

                return 'computed:' + this.msg + this.another + app1;

            }

        },

        methods: {

            submit: function () {

                this.count++

            }

        }

    })

</script>

</html>

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 这篇笔记主要包含 Vue 2 不同于 Vue 1 或者特有的内容,还有我对于 Vue 1.0 印象不深的内容。关于...
    云之外阅读 5,088评论 0 29
  • vue 2.0 渐进式框架 MVC 单向通信 > m:model 数据层 保存数据 > v:view视图层 用户界...
    web前端ling阅读 780评论 0 0
  • pyspark.sql模块 模块上下文 Spark SQL和DataFrames的重要类: pyspark.sql...
    mpro阅读 9,545评论 0 13
  • Vue 实例 属性和方法 每个 Vue 实例都会代理其 data 对象里所有的属性:var data = { a:...
    云之外阅读 2,268评论 0 6
  • 我明天就要考试了,并且是我最后一次考试了,因为我们这是小升初考试。我很舍不得和我的荷包蛋老师离开。 ...
    战立兴阅读 451评论 0 0