vue 一些知識點隨筆

2019/6/20
vue封裝組件
1.創建底層子組件

<template>
<!-- 子組件 -->
     <div>
        <i-form :model="formRight" label-position="right" :label-width="80">
        <Row>
            <i-col span="8">
                <Form-item :label="label">
                    <i-input :value.sync="formRight.input1" :placeholder="placeholder"></i-input>
                </Form-item>
            </i-col>
            <i-col span="8">
                <Form-item :label="labels">
                    <i-input :value.sync="formRight.input1" :placeholder="placeholders"></i-input>
                </Form-item>
            </i-col>
            <!-- <i-col span="8">
                <Form-item label="經營者">
                    <i-input :value.sync="formRight.input2" placeholder="經營者"></i-input>
                </Form-item>
            </i-col> -->
            <i-col span="8">
               <Button type="info">查詢</Button>
               <Button type="warning">重置</Button>
            </i-col>
        </Row>
    </i-form>
     </div>
</template>
props: {
    label: String, 
    placeholder: String,
    labels:String,
    placeholders: String   
},

在子組件中,如果使用props向父組件傳值時,則無需在data裏return,否則會報重複定義的錯誤。

2019-06-24
點擊事件只觸發一次:

<a v-on:click.once="doThis">觸發一次</a>

勾選框綁定v-model

<input type="checkbox" id="checkbox" v-model="checked">
<label for="checkbox">{{ checked }}</label>

//data裏需要定義checked:true

2019-7-27
列表中根據某值過濾數據時

==感覺一直寫不好for-if循環,每次必卡死瀏覽器…

判斷數組中對象的某個屬性等於0時,顯示這條信息

let arr1 = data.filter(function (item) {
    return item.status== "0";
  })
  this.list= arr1;
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章