vue.js事件與屬性

來源:互聯網
上載者:User

標籤:prevent   lower   upper   eve   ext   let   pac   can   event   

事件:

  事件冒泡行為:

    1、@click="show($event)"

      show:function (ev) {

        ev.cancelBubble=true;

      }

     2、@click.stop="show()"

  事件捕獲行為:

    <div v-on:click.capture="doThis">...</div>

  連用:<a v-on:click.stop.prevent="doThat"></a>

  事件預設行為:

    1、ev.preventDefault();

    2、@contextmenu.prevent 

   鍵盤事件行為:

    1、@keydown  可以有 $event ev.keycode

    2、@keyup

    3、斷行符號鍵@keyup.13或者@keyup.enter;@keydown.13,@keydown.enter

      同理有上下左右鍵up,down,left,right.還有space,esc,delete,tab

屬性:

    v-bind:src=""   width/height/title等

    簡寫::src=""

    <img :src="url" alt=">

    class與style:

      :class   v-bind:class=""

      :style   v-bind:style=""

 

      :class="[r,b,c]" r,b,c是data中的資料

      :class="[r]"

      :class="{r:true}"添加上class

      :class="{r:false,b:true}"沒添加上class r,只添加了b

 模板:

    {{msg}}  資料更新模板變化

    {{*msg}} 資料只綁定一次

    {{{msg}}} HTML轉義輸出

過濾器:

    系統提供一些過濾器:

     例: {{‘welcome‘|capitalize}} {{‘welcome‘|uppercase}} {{‘WELCOME‘|lowercase|capitalize}}

      {{ message | filterA }}

      {{ message | filterA | filterB }}       

      {{msg|currency ‘參數‘ }}

     例: {{12|currency ‘¥‘}} 結果 ¥12

互動:

    

 

vue.js事件與屬性

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.