欢迎您访问南京安优网络官方网站,本公司专注于:网站制作、小程序开发、网站推广。 24小时服务热线:400-8793-956
当前位置:南京网站制作公司 > 资讯中心 > 网站知识
南京小程序开发公司阐述Microsoft小部件提交表单操作示例
来源:南京网站制作 时间:2019-05-24 08:20:06

本文南京小程序开发公司阐述了微信小程序的提交表单操作。分享供您参考,如下:

 
表单组件也存在于Wechat小程序中。bindsubmit属性可用于触发表单中数据的提交事件。鞋带的参数如下:
 
event.detail = {value : {'name': 'value'} , formId: ''}
 
与普通网页一样,该名称需要上传以形成组件,例如输入以设置名称属性,其中表单传递参数,使用名称作为键。
 
提交操作由<button />组件控制,其表单类型以<form />形式提交,如下所示:
 
<button form-type= "submit" class='search'> <span> start calculation </span> </button>
单击此按钮时,将触发绑定绑定的JS文件中的事件,例如:
 
<form bindsubmit="formSubmit" bindreset="formReset"> 
<input type="text" name="price"/>
<button form-type= "submit" class='search'> <span> start calculation </span> </button>
</form>
在这里,单击此按钮调用JS中的formSubmit并可以在formSubmit事件e.detail.value.price中使用JS中的表单Submit定义如下:
 
formSubmit: function (e) {
 this.setData({
  Price: E. detail. value. price, // with E. detail. value. price, get the value of the name as the price component in the form and assign it to the price variable defined in the JS file data
 })
 Var that = this; // In the success section, this is invalid. You need to assign this to that first, and call that instead of this, such as: that. setData ({})
 Wx. request ({// completes information exchange using wx. request provided by wechat)
  Url: config. service. XXXX, // URL value is uniformly defined in configuration. js, var config = require ('. /. / config') at the beginning of this js; introduced
  header: {
   "Content-Type": "Application/x-www-form-urlencoded"//Pass parameters using form
  },
  method: "POST",
  dataType:"json",
  Data: Util. json2Form ({price: this. data. price}), /// The data to be delivered is converted to annotated form data format using json2Form in util. JS
  Success: function (res) {//res is the data returned and success is the execution part after the response is successful
   Console. log (res. data) // Display the data carried in Res
  },
  Complete: function (res) {// complete is similar to final and must be executed at last
   If (res == null | res. data == null) {// If the return value is empty, the network request is prompted to fail
   Console. error ('network request failed');
   return;
   }
  }
  })
 },
util.js的内容:
 
 
function json2Form(json) {
 var str = [];
 for (var p in json) {
 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(json[p]));
 }
 return str.join("&");
}
module.exports = {
 json2Form: json2Form,
}
 
wx.request您还可以使用功能JSON格式传输数据,但个人背景不用于处理JSON文件。
 
我希望南京小程序开发公司的这篇文章对你的微信小程序的开发有所帮助。

本文地址:http://www.njanyou.cn/web/2509.html
Tag:
专业服务:南京网站制作,南京网站制作公司,南京网站建设公司
联系电话:025-65016872
上一篇: 如何快速构建域权限
下一篇: 承包和建筑行业网站 - 需要关注的重点
最新案例
永银
永银
珠海跨境电商
珠海跨境电商
五颗星商城
五颗星商城
上海万客生鲜超市
上海万客生鲜超市
一九在线商城
一九在线商城
你可能感兴趣
小型企业平稳运营所需的 5 种软件类型
为什么每个人都在谈论 Advantage+ Creative
27 关于 Bing PPC 的统计数据
改善编程和 QA 之间协作的 4 种方法
您的网站给人留下第一印象:为什么好的网页设计对企业至关重要
网页设计和内容营销:最大限度地提高博客参与度的 6 个技巧
所有重要的 GA4 指标
ClickFunnels 与 Kajabi:详细比较
最后更新
打造直观体验:UX 和 UI 矩阵 了解 Advantage+ 定位 我们所知道的关于大规模谷歌算法泄漏的一切 如何撰写吸引受众注意力的营销电子邮件 如何使用数据抓取进行有效的竞争分析:分步指南 优化医疗保健提供商的 SEO 和在线形象:2024 年的最佳实践 Elementor:网站建设的首选(原因如下) 产品系列页面:提高电子商务转化率的设计策略
服务项目
南京网站制作 营销型网站 微信营销 IDC网站 精品案例