# 組件
*****
在微信小程序中的組件都是雙標簽使用
*****
### 1.view
>塊級元素
*****
### 2.text
>行內元素
*****
### 3.image
**image組件默認寬度340rpx、高度240rpx,image組件中二維碼/小程序碼圖片不支持長按識別。僅在wx.previewImage中支持長按識別**
### 4.input
>input 標簽最好不要設計寬為100%
*****
#### 常用的屬性
| 屬性名 | 類型 | 默認值 | 說明 | 最低版本 |
| --- | --- | --- | --- | --- |
| value | String | | 輸入框的初始內容 | |
| type | String | "text" | input 的類型(有appid才有效果) | |
| password | Boolean | false | 是否是密碼類型 | |
| placeholder | String | | 輸入框為空時占位符 | |
| placeholder-style | String | | 指定 placeholder 的樣式 | |
| placeholder-class | String | "input-placeholder" | 指定 placeholder 的樣式類 | |
| disabled | Boolean | false | 是否禁用 | |
| maxlength | Number | 10 | 最大輸入長度,設置為 -1 的時候不限制最大長度( 例如:最大10個字母或者中文 ) | |
~~~
password=“{{true}}” //是密碼類型
maxlength=“{{2}}” ?//或者 maxlength=“2”
value="默認值" // 或者value="{{默認值}}"
~~~
#### 常用的事件
| bindinput | EventHandle | | 當鍵盤輸入時,觸發input事件,event.detail = {value, cursor},處理函數可以直接 return 一個字符串,將替換輸入框的內容。 | |
| --- | --- | --- | --- | --- |
| bindfocus | EventHandle | | 輸入框聚焦時觸發,event.detail = {value: value} | |
| bindblur | EventHandle | | 輸入框失去焦點時觸發,event.detail = {value: value} | |
事件步驟:
1.綁定事件
> bindinput="onBindInput"
2.通過事件函數獲取輸入的值
> e.detail.value
3.將獲取到的值保存在data中
> 注意: 保存是 this.setData( { } ) ; 獲取是this.data.xxx
4.data中的值展示在頁面上
*****
### 5.button
### 常用的屬性
size 按鈕的大小
> default mini
~~~
<button size="mini">登錄</button>
~~~
type 按鈕的類型 , 不能與背景樣式一起使用
> default warn primary
~~~
<button type="warn">登錄</button>
~~~
plain 按鈕鏤空
> plain ="{{true}}" // true false
~~~
<button type="warn" plain="true">登錄</button>
~~~
disable 按鈕不可點擊
~~~
<button type="warn" plain="true" disabled="true">登錄</button>
~~~
loading 按鈕顯示進度條
~~~
<button type="warn" plain="true" loading="true">登錄</button>
~~~
hover-class 按鈕按下的樣式
> 可以自定義任意按鈕按下的樣式,例如,按下時改變透明度
~~~
//buttton.wxml布局
<button type="warn" plain="true" loading="true">登錄</button>
//樣式
.btn{
background: orange;
}
~~~
form-type 指定button為表單類型,即可提交表單
~~~
//buttton.wxml布局
<form bindsubmit="obBindSubmit">
? ?<input placeholder='請求用戶名' name="username"></input>
? ?<input placeholder='密碼' password name="password"></input>
? ?<button form-type='submit'>點擊提交表單</button>
?</form>
?// buttton.js
?obBindSubmit:function(e){
? ?console.log(e.detail.value) ?//{username: "xxxx", password: "xxxxx"}
}
~~~
open-type 屬性
微信開放能力,即獲取微信賬號 的信息
> 例如:open-type="getUserInfo";獲取用戶信息,可以從bindgetuserinfo回調中獲取到用戶信息
>
> (**第一次調用會彈出:微信授權對話框**)
~~~
//buttton.wxml布局 ?
<button open-type='getUserInfo' bindgetuserinfo="onbindgetuserinfo">getUserInfo</button>
?
// buttton.js
onbindgetuserinfo:function(e){
? ?console.log(e.detail.userInfo) // {nickName: "xxx", gender: 0, language: "zh_CN",..}
}
~~~
| 值 | 說明 | 最低版本 |
| --- | --- | --- |
| contact | 打開客服會話,與微信小程序的客服會話 | [1.1.0](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) |
| share | 觸發用戶**轉發小程序**給微信朋友,使用前建議先閱讀[使用指引](https://developers.weixin.qq.com/miniprogram/dev/api/share.html#%E4%BD%BF%E7%94%A8%E6%8C%87%E5%BC%95) | [1.2.0](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) |
| getUserInfo | 獲取用戶信息,可以從bindgetuserinfo回調中獲取到用戶信息。(**第一次調用會彈出:微信授權對話框**) | [1.3.0](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) |
| getPhoneNumber | 獲取用戶手機號,可以從bindgetphonenumber回調中獲取到用戶信息,(**默認個人是不能獲取**)[具體說明](https://developers.weixin.qq.com/miniprogram/dev/api/getPhoneNumber.html) | [1.2.0](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) |
| launchApp | 打開APP,可以通過app-parameter屬性設定向APP傳的參數[具體說明](https://developers.weixin.qq.com/miniprogram/dev/api/launchApp.html) | [1.9.5](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) |
| openSetting | 打開**授權設置**頁 | [2.0.7](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) |
| feedback | 打開微信的“意見反饋”頁面,用戶可提交反饋內容并上傳[日志](https://developers.weixin.qq.com/miniprogram/dev/api/getLogManager.html)到**微信小程序管理平臺**,開發者可以登錄[小程序管理后臺](https://mp.weixin.qq.com/)后進入左側菜單“客服反饋”頁面獲取到反饋內容 | [2.1.0](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) |
- Javascript
- 組成
- Web API
- 初步認識DOM
- 經典案例 (使用獲取id的方法)
- 節點和元素
- 經典案例 (使用獲取節點和元素的方法)
- 函數
- 作用域鏈
- Array對象的方法
- String對象的方法
- 綁定事件
- 事件委托
- 邏輯運算
- js高級(面向對象、)
- 基本知識
- 數據類型
- 基本包裝類型的使用
- 定義變量的區別
- JavaScript對象的動態特性
- 關鍵字in
- 關鍵字delete
- 運算符
- 創建對象的方式
- 回調函數
- 高階函數
- 構造器屬性
- this指向
- hasOwnProperty屬性
- 私有成員和特權方法
- 面向對象和面向過程的基礎
- 異常捕獲
- 構造函數和普通函數的區別
- 構造函數的補充
- 原型
- 原型圖
- 獲取原型對象的方法
- 原型對象的訪問和設置
- 判斷某個對象是否是指定實例對象的原型對象
- constructor
- isPrototypeOf
- instanceof
- 檢測對象是公有還是私有
- 核心概念
- 繼承
- 混入式繼承
- 原型式繼承
- 原型鏈繼承
- 借用構造函數繼承(call繼承,經典繼承)
- 組合式繼承(推薦)
- class繼承
- __ proto __屬性
- call方法和apply方法
- Fuction相關知識
- 創建函數的方式
- eval函數
- 淺拷貝和深拷貝
- 淺拷貝
- 深拷貝
- Object相關知識
- Object原型屬性和方法
- Object靜態成員對象
- 案例
- 數組去重
- 閉包
- 語法
- DOM事件和閉包
- 定時器和閉包
- 即使對象初始化
- 閉包的變形
- 設計模式
- 單例模式
- 發布訂閱模式(觀察者模式)
- 工廠模式
- 命名空間模式
- 同步和異步
- 垃圾回收機制
- get和set
- JQuery
- 動畫方法
- 事件
- 方法
- 節點
- 方法er
- HTML + CSS
- 經驗
- flex布局
- px,em ,rem區別
- 清除浮動
- Less
- UI框架
- 一.Bootstrap框架
- 常用類名
- 二 .Animate.css
- 三.WOW.JS
- 四.scrollReveal.js
- 五.zepto框架
- zepto選擇器
- 滑動事件
- tap觸摸事件
- zepto動畫
- 六,swipe框架
- 分頁器
- 左右按鈕和循環輪播
- 底部滾動和輪播方向
- 自動播放和切換效果
- 移入移除事件
- swipe結合animate.css
- 總結
- 滾滾屏
- 自動化構建工具
- 1.gulp
- 使用gulp編譯less成css,并最終壓縮css
- 壓縮css
- 合并和壓縮js
- 壓縮圖片
- 編寫server服務
- 包管理器
- 介紹
- brew
- npm十全大補湯
- ES6
- class類
- class類的使用
- class類的繼承結構
- let 和const
- 結構語法
- 模板字符串
- 化簡寫法
- 形參的默認值
- ...rest參數
- rest剩余參數
- 擴展參數
- 正則表達式
- 創建正則表達式的方式
- 構造函數
- 字面量的方式
- 其他(修飾符)
- 判斷是否匹配成功
- 正則表達式案例
- 常見的匹配原則
- 驗證密碼長度
- 表單驗證
- 正則提取
- 正則替換
- vue
- 插值操作
- Mustache語法
- 過濾器
- 綁定相關知識
- 綁定對象
- 單向綁定
- 雙向綁定
- 綁定屬性
- 動態綁定style
- 綁定事件
- 補充
- 綁定語法
- 基礎
- vue介紹
- MVVM
- 計算屬性
- 指令
- v-cloak
- 顯示和隱藏
- 循環
- 自定義指令
- 本地緩存
- localStorage
- sessionStorage
- 對象劫持
- 組件
- 局部組件
- 父子組件
- 全局組件
- 組件訪問實例數據
- 父傳子
- 子傳父
- 兄弟傳兄弟
- 插槽
- methods,computed,watch的區別
- Vue.observable()
- vue.config.js配置
- 修飾符
- .sync修飾符
- $attrs和$listeners
- Node.js
- 使用Node執行js代碼的兩種方式
- 交互模式
- 解釋js文件
- http模板
- request對象的使用
- express框架
- 安裝
- post
- 獲取請求參數
- post返回頁面
- 重定向到別的接口
- get
- 返回頁面
- get獲取請求參數
- 請求靜態資源
- 熱重啟
- Ajax
- 請求方式
- get請求
- post請求
- jQuery中的ajax方法
- JQuery中的get請求
- jQuery中的post請求
- 微信小程序
- 認識
- 引入樣式的方式
- 綁定數據
- 小程序組件
- scroll - view 可滾動視圖區域
- 發起請求
- template模板
- rich-text
- web-view
- open-data
- checkbox組件
- label組件
- radio組件
- picker組件
- swiper組件
- Git
- 跨域
- 左側固定,右側自適應
- vuex
- 如何解決vuex頁面刷新數據丟失問題
- 數據結構
- 樹
- 問題累積
- Axios
- 前端路由