日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問(wèn)題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
創(chuàng)新互聯(lián)百度小程序教程:form表單
  • form 表單
    • 屬性說(shuō)明
      • report-type 有效值
      • report-type 為 subscribe 時(shí),event.detail.formId 說(shuō)明
      • report-type 為 subscribe 時(shí),status 和 message 具體值
    • 示例
      • 代碼示例 1:普通表單
      • 代碼示例 2:模板類型表單

    form 表單

    解釋:表單,將 form 組件內(nèi)用戶輸入 / 選擇的、、、提交。當(dāng)

    表單中 form-type 為 submit 時(shí),點(diǎn)擊的
  •  
     
     
    1. Page({
    2. formSubmit(e) {
    3. // 此時(shí) formId 為 'BD0001-formId'(非真實(shí)數(shù)據(jù))
    4. swan.showModal({
    5. title: 'template-id 為 string',
    6. content: e.detail.formId
    7. });
    8. }
    9. });

    2. 當(dāng) template-id 為 Array 時(shí)(基礎(chǔ)庫(kù) 3.170.1 開(kāi)始支持),event.detail 的 formId 為 Object ,其中對(duì)象的 key 為 template-id ,value 為其對(duì)應(yīng)的 formId 。舉例如下

    • SWAN
    • JS
     
     
     
     
     
     
    1. Page({
    2. data: {
    3. templateId: ['BD0001', 'BD0002']
    4. },
    5. formSubmit(e) {
    6. // 此時(shí) formId 為 {'BD0001': 'BD0001-formId', 'BD0002': 'BD0002-formId'}(非真實(shí)數(shù)據(jù))
    7. swan.showModal({
    8. title: 'template-id 為 Array',
    9. content: JSON.stringify(e.detail.formId)
    10. });
    11. }
    12. });

    如果 Array 中的 template-id 超過(guò)三個(gè),返回的 formId 為空字符串,舉例如下:

    • SWAN
    • JS
     
     
     
     
     
     
    1. Page({
    2. data: {
    3. templateId: ['BD0001', 'BD0002', 'BD0003', 'BD0004']
    4. },
    5. formSubmit(e) {
    6. // 此時(shí) formId 為 ''
    7. swan.showModal({
    8. title: 'template-id 超過(guò)三個(gè)',
    9. content: e.detail.formId
    10. });
    11. }
    12. });

    如果 Array 中有重復(fù)的 template-id ,重復(fù)的 template-id 對(duì)應(yīng)的 formId 只返回一次,舉例如下:

    • SWAN
    • JS
     
     
     
     
     
     
    1. Page({
    2. data: {
    3. templateId: ['BD0001', 'BD0001', 'BD0002']
    4. },
    5. formSubmit(e) {
    6. // 此時(shí) formId 為 {'BD0001': 'BD0001-formId', 'BD0002': 'BD0002-formId'}(非真實(shí)數(shù)據(jù))
    7. swan.showModal({
    8. title: '有重復(fù)的 template-id',
    9. content: JSON.stringify(e.detail.formId)
    10. });
    11. }
    12. });

    注意:在提交 form 表單時(shí),將會(huì)彈出模板消息授權(quán)彈窗,用戶授權(quán)后才能在 event.detail 中獲取被授權(quán)模板消息的 formId 。

    report-type 為 subscribe 時(shí),status 和 message 具體值

    status 為 Number 類型,message 為 String 類型,當(dāng)用戶永久拒絕授權(quán)的時(shí)候,建議開(kāi)發(fā)者不要再展示訂閱消息授權(quán)面板入口。

    status message
    500101用戶永久拒絕授權(quán)
    500102用戶單次拒絕授權(quán)
    500103用戶取消授權(quán)
    500104請(qǐng)求模板內(nèi)容失敗
    500105請(qǐng)求 formId 失敗

    示例

    跳轉(zhuǎn)編輯工具

    在開(kāi)發(fā)者工具中打開(kāi)

    在 WEB IDE 中打開(kāi)

    掃碼體驗(yàn)

    代碼示例

    請(qǐng)使用百度APP掃碼

    代碼示例 1:普通表單

    • SWAN
    • JS
     
     
     
    1. bindreset="formReset">
    2. 開(kāi)關(guān)選擇器
    3. 開(kāi)關(guān)
    4. 單項(xiàng)選擇器
    5. 單選項(xiàng)一
    6. 單選項(xiàng)二
    7. 多項(xiàng)選擇器
    8. 多選項(xiàng)一
    9. 多選項(xiàng)二
    10. 多選項(xiàng)三
    11. 滑塊選擇器
    12. 輸入框
    13. 提交表單
     
     
     
    1. Page({
    2. formSubmit(e) {
    3. console.log('form發(fā)生了submit事件,攜帶數(shù)據(jù)為:', e.detail.value);
    4. swan.showModal({
    5. content: '數(shù)據(jù):' + JSON.stringify(e.detail.value),
    6. confirmText: '確定'
    7. });
    8. },
    9. formReset(e) {
    10. console.log('form表單發(fā)生了', e.type);
    11. }
    12. });

    代碼示例 2:模板類型表單

    在開(kāi)發(fā)者工具中打開(kāi)

    在開(kāi)發(fā)者工具中打開(kāi)

    在 WEB IDE 中打開(kāi)

    • SWAN
    • JS
     
     
     
    1. report-submit
    2. report-type="subscribe"
    3. template-id="BD0003"
    4. subscribe-id="8026"
    5. bindsubmit="reportFormSubmit"
    6. bindreset="reportFormReset">
    7. report-type為subscribe
    8. report-submit
    9. report-type="default"
    10. bindsubmit="reportFormSubmit"
    11. bindreset="reportFormReset">
    12. report-type為default
     
     
     
    1. Page({
    2. onLoad() {
    3. swan.showToast({
    4. title: '此組件需要登錄態(tài),請(qǐng)先點(diǎn)擊下方的按鈕登錄',
    5. icon: 'none'
    6. })
    7. },
    8. login(e) {
    9. // 此組件需要在登陸態(tài)下使用
    10. console.log('登錄信息:', e);
    11. if (e.detail.errCode === '10004') {
    12. swan.showToast({
    13. title: '用戶未登錄',
    14. icon: 'none'
    15. });
    16. return;
    17. }
    18. swan.showToast({
    19. title: '用戶登錄成功',
    20. icon: 'none'
    21. });
    22. },
    23. formSubmit(e) {
    24. swan.showModal({
    25. title: '表單數(shù)據(jù)',
    26. content: JSON.stringify(e.detail.message) + '/' +JSON.stringify(e.detail.status),
    27. confirmText: '確定',
    28. showCancel: false
    29. });
    30. }
    31. });

    網(wǎng)站標(biāo)題:創(chuàng)新互聯(lián)百度小程序教程:form表單
    本文路徑:http://www.5511xx.com/article/dhgspjo.html