2018年7月28日 星期六

[JS/Vue]check box 勾選後在別處呈現 & radio 在各自獨立同名class div中卻是單選

在 input type="checkbox"
加入 attr. v-model="checkboxArrayName",
可以將表格中checkbox暫時存入array,
使用 v-for="item in checkboxArrayName" {{ item }} 將其表達呈現出來。

在 input type="radio"
加入 attr. v-model="radioName",
即使沒有 <form>也能圈在一起,變成單選。

2018年7月27日 星期五

[JS/Vue]讓點擊 a href="#" 不要彈到最上方:preventDefault()

preventDefault()的對象是event
寫法是:
$('a.selector').on('click', function(evt){
  evt.preventDefault();
})

假設href="#" 後方接一個網址,一樣不會連過去,
如同字面一樣的方法。
假設改成表單,則是停止送出(submit)

參閱https://cn.vuejs.org/v2/guide/events.html#%E4%BA%8B%E4%BB%B6%E4%BF%AE%E9%A5%B0%E7%AC%A6

2018年6月6日 星期三

[HTML] pug的註解、標籤後方有本文的處理、插值(變數)、pug-loader

https://www.getit01.com/p2018020125177324/
https://www.getit01.com/p2018020125310457/

pug中要註解可選擇是否生成在Html:
// 這樣寫會在 html生成
//- 前方有減號,這樣寫不會

使用<br>結束一行再輸入文字該怎麼寫呢?
用 enter附近的 " | " 符號例如:
<br/>
要輸入的文字

在pug裏會寫成:
br
| 要輸入的文字

<h1>title<span>sample</span>輸入的文字</h1>
也是一樣的寫法:
h1 title
  span sample
  | 輸入的文字
或是:
h1. title #[span sample] 輸入的文字

插值
https://pugjs.org/language/interpolation.html
在 HtmlWebpackPlugin 傳 data 變數
https://medium.com/@milkmidi/test-c3a23ca0cc55 - Milk Midi 奶綠茶

[Ang] 指令 directive:元件型、屬性型、結構型

component directives

attribute directives
兩種:ngStyle(直接鍵入a-選單尋找) ngClass

structural directives
三種:ngIf ngSwitch ngFor

[Ang]雙向繫結 two-way binding 、範本參考變數 template reference variables

雙向繫結 two-way binding  [( )]
會自動做到 {{屬性}} 及 (事件),

在app.module.ts 中import ngModel:
import { FormsModule } from '@angular/forms';

component 建立 propertyName,
template tag裡寫入 [(ngModel)]="propertyName"
也可以輸入a-,vs code擴充的 angular extension pack會自動跳出選單,
tab之後就會變成 [( ... )],非常方便。

範本參考變數 template reference variables #name
可套用到任意 tag內,有點類似 id,直接在 template對它進行動作。