# +_一些小狗專案的筆記_C 【一些關於鞭策當天的奇怪筆記】 1. 不要在元件裡面 export type,如果會在其他地方用到應該是要寫在 type 檔案,filterOptions 要進去 Multiple… 裡面拿也是可以直接用這個方法 `type FilterState = InstanceType<type of XXX>['$props']['modelValue']` 2. DogProfile filter 那個直接用就好了不用另外寫一個 type 3. api response 的 interface 可以寫在 api 那包定義,畫面需要的只需要關注 data 其中的 type 就好了 ```typescript // doggySurfingAPI.ts // 新增一個通用的 response 型別 type APIResponse<T> = { status: string message: string data: T } get: <T = any>(url: string, config?: AxiosRequestConfig): Promise<APIResponse<T>> => { return api.get(url, config && { ...config, paramsSerializer: (params) => { return qs.stringify(params, { arrayFormat: 'comma' }) } }) }, // 型別檔案中原本的 Response export interface DeleteDogResponse { status: string message: string data: { message: string } } // 就可以改成 data 裡面的內容 export interface DeleteDogResponse { message: string } ``` 4. @media 斷點可以考慮寫 @mixin 5. quasar 有暴露元件型別! 因為我要用他的元件,所以我直接去拿他的型別是最正確的 `QselectProps['options']` 6. InteractionNeedUI 是在 DogForm 裡面用到 那可以直接在 DogForm instance 拿就好 7. dropdown 改不到樣式(在 `<div id="app">` 外面),所以寫了 :global() 8. 穿透屬性 `v-bind="$attrs"`,所有傳進元件的 props 都應該要定好他要在的 element 位置,即使因為預設是 root element 而剛好不用寫 v-bind 也要明確寫出來 9. 盡量不寫 types/index.d.ts 檔案然後把所有其他檔案 import 進來了,怕會有型別名稱重複的問題