• 03.v-cloak、v-v-text、v-html、v-bind、v-on


    <!DOCTYPE html>

    <html lang="en">

    <head>

      <meta charset="UTF-8">

      <meta name="viewport" content="width=device-width, initial-scale=1.0">

      <meta http-equiv="X-UA-Compatible" content="ie=edge">

      <title>Document</title>

      <style>

        [v-cloak] {

          /* display: none; */

        }

      </style>

    </head>

    <body>

      <div id="app">

        <!-- 使用 v-cloak 能够解决 插值表达式闪烁的问题 -->

        <p v-cloak>++++++++ {{ msg }} ----------</p>

        <h4 v-text="msg">==================</h4>

        <!-- 默认 v-text 是没有闪烁问题的 -->

        <!-- v-text会覆盖元素中原本的内容,但是 插值表达式  只会替换自己的这个占位符,不会把 整个元素的内容清空 -->

        <div>{{msg2}}</div>

        <div v-text="msg2"></div>

        <div v-html="msg2">1212112</div>

        <!-- v-bind: 是 Vue中,提供的用于绑定属性的指令 -->

        <!-- <input type="button" value="按钮" v-bind:title="mytitle + '123'"> -->

        <!-- 注意: v-bind: 指令可以被简写为 :要绑定的属性 -->

        <!-- v-bind 中,可以写合法的JS表达式 -->

        <!-- Vue 中提供了 v-on: 事件绑定机制 -->

        <!-- <input type="button" value="按钮" :title="mytitle + '123'" v-on:click="alert('hello')"> -->

        <input type="button" value="按钮" @click="show">

      </div>

      <script src="./lib/vue-2.4.0.js"></script>

      <script>

        var vm = new Vue({

          el: '#app',

          data: {

            msg: '123',

            msg2: '<h1>哈哈,我是一个大大的H1, 我大,我骄傲</h1>',

            mytitle: '这是一个自己定义的title'

          },

          methods: { // 这个 methods属性中定义了当前Vue实例所有可用的方法

            show: function () {

              alert('Hello')

            }

          }

        })

        /* document.getElementById('btn').onclick = function(){

          alert('Hello')

        } */

      </script>

    </body>

    </html>

    <!-- 1. 如何定义一个基本的Vue代码结构 -->

    <!-- 2. 插值表达式 和  v-text   -->

    <!-- 3. v-cloak -->

    <!-- 4. v-html -->

    <!-- 5. v-bind   Vue提供的属性绑定机制   缩写是 : -->

    <!-- 6. v-on     Vue提供的事件绑定机制   缩写是 @ -->

  • 相关阅读:
    基准测试工具 pgbench 之一初步测试
    postgresql 9.1 kernel.shm 设置不当导致 FATAL: could not create shared memory segment
    centos 6.8 + postgresql 9.6 + make
    plpgsql 执行块
    postgresql 10.1 分区表之 list 分区
    debian 各个版本的代号
    debian 8.2 bond 双网卡
    centos 6.8 + postgresql 9.6 + adminpack
    centos 6.8 + postgresql 9.6 + pldebugger/pldbgapi
    postgresql 10.1 参数的初步了解 Preset Options
  • 原文地址:https://www.cnblogs.com/cristin/p/9115489.html
Copyright © 2020-2023  润新知