有任何意见或建议都欢迎提 issue
MIT
:dog: 微信小程序 - 扩展插件(发送请求、Promise API、表单验证、Restful API)
License: MIT License
有任何意见或建议都欢迎提 issue
MIT
比如我要校验邮箱的唯一性,需要等到接口返回 是个异步的
需求:当input失去焦点时,实时验证,并提示用户,
需要单独验证某个字段,
求指教,谢谢
在引入这个库后,如何进行请求的取消呢,不会再发起request请求
不知道是撒原因
类似elementui那种动态循环表单验证
比如
input是动态生成的,
Ep:
必填:<input name="info[0]">
必填:<input name="info[1]">
必填:<input name="info[2]">
我看这个校验是通过name来写的rule和message ,但是对于上面的这个情况,该怎么操作呢?
如题
不用form包裹,直接验证某个input可以吗
个人觉得,您可以把所有的方法都进行promse封装,然后里面的api统一使用wxService.api来调用
export default (new WxValidate(
{ // 验证字段规则
content: { required: true, minlength: 5 },
images: { images: true, },
videos: { videos: true, }
},
{ // 验证字段提示信息
content: { required: "请输入", minlength: "请最少填写5个字" }
}))
.addMethod('images', (value, _, data) => value.length || data.videos.length)
.addMethod("videos", (value, _, data) => value.length || data.images.length)
1、addMethod 方法应该返回this
2、addMethod 方法应该有第三个参数 data(images和videos 两个字段只要有一个为真就整个验证器会返回真)
VM5199:1 thirdScriptError
sdk uncaught third Error
Unexpected token export
SyntaxError: Unexpected token export 因为我将es6转es5 关闭了
App.WxService.navigateTo('/pages/test', {
msg: '中文乱码',
})
您好,目前项目中使用到您的验证模块很好用感谢您的分享
现在有个建议就是,关于 wxValidate.checkForm 时是否可以将参数改成需要验证的value对象而不是整个form事件对象,这样对value可以做到部分格式化然后再验证 ^_^
666
你好,我是 wxPromise 的作者,我看了咱俩的库实现的东西上基本没有什么冲突的。
我一直想设计一个像 element-ui 那样的表单验证功能,用户只用配置 rule 即可,看了你这个我觉得是我想要的。
我想邀请你,在我的库中作为一个API引入。如果不方便,我也可以自己研究下你的源码
当遇到radio是需要隐藏dom 元素 表单还会进行隐藏dom 元素的验证
下面这个表单验证的文档中有错误
https://github.com/skyvow/wx-extend/blob/master/docs/components/validate.md
下面这段代码有两个问题:
1、这行注释 // 调用验证方法,传入参数 e 是 form 表单组件中的数据
,描述的内容违背了惯例,容易让人误解,常规情况下 submitForm(e)
中的 e
是form的提交事件;
2、代码中的 WxValidate.checkForm(e)
的 参数 e 不对,应该是 e.detail.value
// 调用验证方法,传入参数 e 是 form 表单组件中的数据
submitForm(e) {
const params = e.detail.value
console.log(params)
// 传入表单数据,调用验证方法
if (!this.WxValidate.checkForm(e)) {
const error = this.WxValidate.errorList[0]
return false
}
},
如题...
我看了代码里面是/^1[34578]\d{9}$/,现在联通有16开头的
建议在required总添加对object的判断:
required(value, param) {
if (!that.depend(param)) {
return 'dependency-mismatch'
} else if (typeof value === 'number') {
value = value.toString()
} else if (typeof value === 'boolean') {
return !0
} else if (Object.prototype.toString.call(value) === "[object Object]") {
return Object.keys(value).length;
}
return value.length > 0
},
参数arguments设置的有没有问题?这样吧?
if (typeof config === 'string') {
config = Object.assign({}, {
url: arguments[0]
}, arguments[1])
}
//检查是否已有用户信息
checkUserInfo() {
const { prowx } = app;
// 全局 storage
prowx.getStorage({
key: 'userInfo'
}).then(res => {
res
debugger
}).catch(res => {
res
debugger
})
wx.getStorage({
key: 'userInfo',
success: function (res) {
debugger
console.log(res.data)
},
fail: function (res) {
debugger
console.log(res.data)
},
})
},
如上代码所示,原生的可以进入fail回调,wx-extend 没有进入,
请问up主,这是什么原因?
比如:
` this.interceptors.use({
request(request) {
request.header = request.header || {};
request.header['content-type'] = 'application/json';
if (request.url.indexOf('/yse') > -1 && request.url.indexOf('/create_user') < 0) {
var vsk = wx.getStorageSync('sk');
if (!sk) {
async function fn1() {
var promise = new Promise(function (resolve, reject) {
wx.login({
success: function (res) {
resolve(res.code);
}
});
});
var code = await promise;
// 我始终无法设置code到header,这是一个异步的,怎么同步设置呢,求解,谢谢!
request.header['code'] = code;
}
} else {
request.header['sk'] = sk;
}
}
wx.showLoading({
title: '加载中...',
})
return request;`
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.