web前端學習/工作筆記(二)

  1. p文本換行
  • display: block; word-wrap: break-word;
  1. 樣式中加變量:
  • :style是對象,裏面屬性是鍵值對
    :style="{‘background-image’:‘url(’+item.img+’)’,background:‘red’}"
  1. 第一個元素與父容器之間的間距用padding而不用margin,margin會撐開

  2. 當你設置一個元素爲 box-sizing: border-box; 時,此元素的內邊距和邊框不再會增加它的寬度

  3. 樣式裏數值計算

  • height: calc(100% - 60px);
  1. 設置div背景顏色透明度,內部元素不透明:
  • .demo{  background-color:rgba(255,255,255,0.15) }
  1. 商品列表佈局換行
    display: flex; flex-wrap: wrap;

  2. class三元表達式

  • :class="item.state1 ? ‘note’:‘note-no’"
    非三元::class=’{bg:index
    BoxSelectedIndex}’

  • 條件判斷,:class="[right_con_left,{‘fold’:!showItemTree}]

2018.11.26
18. 佔位符

  • == 普通的英文半角空格   ==   ==   == no-break space (普通的英文半角空格但不換行)   == 中文全角空格 (一箇中文寬度)   ==   == en空格 (半個中文寬度)   ==   == em空格 (一箇中文寬度)   == 四分之一em空格 (四分之一中文寬度) 相比平時的空格( ),nbsp擁有不間斷(non-breaking)特性。即連續的nbsp會在同一行內顯示。即使有100個連續的nbsp,瀏覽器也不會把它們拆成兩行。
  1. 水平垂直居中
    display: flex; align-items: center;//垂直居中
    justify-content: center;//水平居中
    or
    display: flex; flex-direction: column; text-align: center;//水平居中
    justify-content: center//垂直居中;
  2. 不換行
  • li、a、span行內強制不換行;white-space:nowrap;
  1. ctrl+alt+左右鍵 代碼位置定位

  2. 判斷對象爲空
    Object.keys(對象).length==0

  3. 代碼保持同步:

  • _this.$nextTick(()=>{
    _this.addShortcutsKey(‘enter’, () => {
    _this.closeMyMessageBox()
    })
  1. 解構賦值爲淺拷貝
  • let obj = { }; let { …x } = obj;
    深拷貝:JSON.parse(JSON.stringify(origin));
  1. v-model
  • v-model.trim 將用戶輸入的前後的空格去掉
  • v-model.number 將用戶輸入的字符串轉換成number
  1. radio雙向綁定用
  • :checked而不用v-model
  1. mixin得聲明在調用之前
  2. 一個列表刪除另一個列表中的同一項,先找到index,再用splice(index,1)
  • var index = this.list.findIndex(function(item){ //根據item中的id屬性來判斷這個item是否是上面id中 //對應的數據,如果是返回一個true ,否返回false,繼續下面的一條數據的遍歷,以此類推 return item.id ==id; //如果返回true,那麼findIndex方法會將這個item對應的id返回到外面接受 });
  1. 彈框代碼模板
  • showCombinedMedicationFun(){
    //todo
    let _this=this
    _this.showCombinedMedication=true
    _this.$nextTick(()=>{
    _this.addShortcutsKey(‘enter’, () => {
    _this.confirmCombinedMedication()
    })
    })
    },
  • confirmCombinedMedication(){
    let _this=this
    _this.closeCombinedMedication()
    },
  • closeCombinedMedication(){
    let _this=this
    _this.showCombinedMedication=false
    },
  1. 數組複製:
    let aa=[1,2,3]
    Let bb=[…] 會覆蓋bb
發佈了57 篇原創文章 · 獲贊 47 · 訪問量 9萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章