form

element upload上传表单验证

こ雲淡風輕ζ 提交于 2020-01-15 07:31:07
代码如下 自己写上传的代码,所以action可以随意写 on-change:根据变化修改from中的file值 亲测有效 没有图片时 添加图片后 <template> <div> <div class="container"> <el-form style="width:60%;" :model="form" status-icon :rules="rules" ref="form" label-width="100px" class="demo-ruleForm" > <el-form-item label="描述" prop="desc"> <el-input type="textarea" maxlength="50" show-word-limit v-model="form.desc"></el-input> </el-form-item> <el-form-item label="添加图片" prop="file" ref="uploadElement"> <el-upload action="#" multiple v-model="form.file" ref="upload" list-type="picture-card" :auto-upload="false" :on-preview="showImg" :on-remove="remove" :on

商品分类页面

本秂侑毒 提交于 2020-01-15 07:17:18
把数据展示出来之后,发现时间栏目是时间戳,那么就要写一个全局的过滤器把时间戳转换成时间 /* 定义一个全局的把后台传过来的时间戳变成自定义事件样式的过滤器 */ Vue . filter ( 'dateFormat' , function ( originVal ) { const dt = new Date ( originVal ) //传入一个时间,然后把这个时间戳new成对象 const y = dt . getFullYear ( ) //获取年份 const m = ( dt . getMonth ( ) + 1 + '' ) . padStart ( 2 , '0' ) //获取月份,由于月份是从0开始的 const d = ( dt . getDate ( ) + '' ) . padStart ( 2 , '0' ) //加一个空字符串是把当前得到的东西转换成字符串 const hh = ( dt . getHours ( ) + '' ) . padStart ( 2 , '0' ) //后面这个方法的作用就是如果不满两位数的话,就用0代替 const mm = ( dt . getMinutes ( ) + '' ) . padStart ( 2 , '0' ) const ss = ( dt . getSeconds ( ) + '' ) .

小程序模板消息改成订阅消息功能开发

白昼怎懂夜的黑 提交于 2020-01-15 03:44:07
前不久小程序突然公共说模板消息要改版了,具体内容可以看这 https://developers.weixin.qq.com/community/develop/doc/00008a8a7d8310b6bf4975b635a401?blockType=1 反正大概意思就是模板消息要停用了,会出一个新的订阅消息替代,订阅消息有两种,一次性订阅和长期订阅。想详细了解可以看文档。这里不再说明,分享一下提供改的的方法(每次小程序突然改动,苦逼的还是我们这些底层程序猿~,说多了都是泪) 以我们公司的小程序为例子,以前模板消息的时候,我们是在button按钮外面套一层form标签,给它加上subumit事件,提交的时候就可以在参数里面活动formId了,然后在被它们传给后端保存起来,7天内有效,想要发通知的时候用一个id就可以了 改版前: <!-- wxml --> <form report-submit bindsubmit='formSubmit'> <button form-type="submit">立即开通</button> </form> <!-- js--> formSubmit(e) { const formId = e.detail.formId app.addForm(formId ) .// 封装的传给后台api } 改版后: <!-- wxml --> <form

post跳转

微笑、不失礼 提交于 2020-01-15 02:13:18
$ . extend ( { StandardPost : function ( url , args ) { var body = $ ( document . body ) , form = $ ( "<form method='post'></form>" ) , input ; form . attr ( { "action" : url } ) ; $ . each ( args , function ( key , value ) { input = $ ( "<input type='hidden'>" ) ; input . attr ( { "name" : key } ) ; input . val ( value ) ; form . append ( input ) ; } ) ; form . appendTo ( document . body ) ; form . submit ( ) ; document . body . removeChild ( form [ 0 ] ) ; } } ) ; 调用 $ . StandardPost ( WEB_PATH + 'order/create_order' , { cart_id : cart_id } ) 来源: CSDN 作者: 北辰_ 链接: https://blog.csdn.net/qq

vue 表单 验证 async-validator

删除回忆录丶 提交于 2020-01-15 00:57:40
1、使用插件 async-validator async-validator 地址: https://github.com/yiminghe/async-validator 2、示例(vue+element-ui) <el-form :model="numberValidateForm" ref="numberValidateForm" label-width="100px" class="demo-ruleForm"> <el-form-item label="年龄" prop="age" :rules="[ { required: true, message: '年龄不能为空'}, { type: 'number', message: '年龄必须为数字值'} ]" > <el-input type="age" v-model.number="numberValidateForm.age" autocomplete="off"></el-input> </el-form-item> <el-form-item> <el-button type="primary" @click="submitForm('numberValidateForm')">提交</el-button> <el-button @click="resetForm('numberValidateForm')"

文件上传和下载实例源码

丶灬走出姿态 提交于 2020-01-14 19:27:19
效果图 首先是封装好的图片类(缩放及生成水印) GDBasic.php <?php /** * GDBasic.php * description GD基础类 */ namespace test\Lib; class GDBasic { protected static $_check =false; //检查服务器环境中gd库 public static function check() { //当静态变量不为false if(static::$_check) { return true; } //检查gd库是否加载 if(!function_exists("gd_info")) { throw new \Exception('GD is not exists'); } //检查gd库版本 $version = ''; $info = gd_info(); if(preg_match("/\\d+\\.\\d+(?:\\.\\d+)?/", $info["GD Version"], $matches)) { $version = $matches[0]; } //当gd库版本小于2.0.1 if(!version_compare($version,'2.0.1','>=')) { throw new \Exception("GD requires GD version '2.0

antd的form组件在form标签外触发验证

帅比萌擦擦* 提交于 2020-01-14 14:54:22
什么情况需要在form标签外触发验证呢? 有,比如新增页是个全屏弹框的自定义组件,这种组件,一般都带有 close icon , 确认 , 取消 按钮。 那不管这种弹框的内容是什么,都是要通过 确认btn 去触发。 写法还是那个写法,就是换个位置调用 如果触发按钮在Form标签内部,就直接在Form标签上绑定onSubmit事件,指向handleSubmit 方法; < Form onSubmit = { handleSubmit } > < / Form > 如果触发按钮在Form标签外部,那哪个按钮操作,它就去调handleSubmit 方法。 比如这样: import React from "react" ; import { connect , DispatchProp } from "react-redux" ; import { Form , Input , Button } from "antd" ; import { FormComponentProps } from "antd/lib/form" ; export interface Props extends DispatchProp { addUserRedux : any ; form : FormComponentProps [ "form" ] ; } const AddUser : React .

extjs创建灵活布局的表单

孤街醉人 提交于 2020-01-14 14:14:02
var form = new Ext . form . FormPanel ( { // var form = Ext.create('Ext.form.Panel',{ title : "灵活布局的表单" , width : 650 , autoHeight : true , frame : true , layout : "form" , // 整个大的表单是form布局 labelWidth : 65 , labelAlign : "right" , items : [ { // 行1 layout : "column" , // 从左往右的布局 items : [ { columnWidth : .3 , // 该列有整行中所占百分比 layout : "form" , // 从上往下的布局 items : [ { xtype : "textfield" , fieldLabel : "姓" , width : 120 } ] } , { columnWidth : .3 , layout : "form" , items : [ { xtype : "textfield" , fieldLabel : "名" , width : 120 } ] } , { columnWidth : .3 , layout : "form" , items : [ { xtype :

form表单重复提交,type=“button”和type=“submit”区别

淺唱寂寞╮ 提交于 2020-01-14 12:11:36
公司测试提了一个项目后台在IE浏览器下(360,firefox就没问题)出现数据重复的问题,调试了好久终于发现问题所在,也不知道是谁写的代码,醉醉的。。。。 错误地点: <input type="submit" value="提交" class="btn" id="formSubmit" onclick="checkForm()" /> type类型写成submit,而在checkForm中也进行了form提交。 type=“button”和type="submit"在IE firefox 360下分别进行submit()提交和走ajax测试: 测试代码: <body> <form id="form1" method="get" > <input name="username" value="zhangsan" /><br> <input name="age" value="20" /><br> <input name="address" value="beijing" /><br> <input name="birthday" value="10-12" /><br> <input name="contactInfo.tel" value="13321464327" /><br> <input name="contactInfo.address" value="hebei" />

美化表单提交按钮的方法

让人想犯罪 __ 提交于 2020-01-14 12:09:06
这几天在做一个表单提交,默认的提交按钮代码样式 Code < form id ="form1" name ="form1" action ="表单提交的URL" method ="get" > < input type ="submit" name ="submit" value ="提交" > </ form > 现在我们可以把这个提交按钮替换成 < form id ="form1" name ="form1" action ="" method ="get" > < img src ="../login.gif" onclick ="document.form1.submit()" name ="submit" > </ form > 或者是 < form id ="form1" name ="form1" action ="" method ="get" > < input type ="image" src ="../login.gif" name ="submit" /> </ form > 我们把input标签直接换了普通的img,而加上了 document.form1.submit ()这个方法,利用这个方法我们可以把一些标签用css进行美化表单按钮 来源: https://www.cnblogs.com/JAMJIA/archive/2009/11/16