Members
(constant) isFlexSupported :boolean
- Source:
是否支持Flex
Type:
- boolean
Methods
isStyleSupport(styleName) → {boolean}
- Source:
检测浏览器是否支持指定的样式
Parameters:
Name | Type | Description |
---|---|---|
styleName |
string | Array.<string> | 样式名称 |
Returns:
是否支持
- Type
- boolean
module:$ui/utils/ajax(options) → {Promise}
ajax 函数
Examples
// 基础用法
ajax({
url: '/api/users'
})
.then(res => {
// to do something...
})
.catch(e => {
// to do something...
})
// url path传参
ajax({
method: 'get',
url: '/api/users/:id',
params: {
id: '123'
}
})
// 发送数据
ajax({
url: '/api/users',
method: 'post',
data: {
name: 'kenny',
password: '123456'
}
})
// 设置请求头
ajax({
url: '/api/users/',
data: {
page: 1,
limit: 10
},
headers: {
'Content-type': 'application/x-www-form-urlencoded'
}
})
// 启用缓存,缓存到内存,刷新页面将失效
ajax({
url: '/api/user',
cache: true
})
// 启用缓存,缓存到LocalStorage
ajax({
url: '/api/user',
cache: {
local: true
}
})
// 启用缓存,缓存到SessionStorage
ajax({
url: '/api/user',
cache: {
session: true
}
})
// 启用缓存,自定义缓存key
ajax({
url: '/api/user',
cache: {
local: true,
key: 'cachekey'
}
})
http发送请求,websocket接收响应,需要与websocket配合
ajax({
url: '/api/user',
socket: true
})
// webscoket 接收转发
ws.on('FwzxSyncCall', function (res) {
if (res && res.NotifyId) {
bus.$emit(res.NotifyId, responseData({data: res.Data}))
}
})
Parameters:
Name | Type | Description |
---|---|---|
options |
object | ajax参数选项. 默认选项值 |
Returns:
promise
- Type
- Promise
module:$ui/utils/date(dateStr, formatopt, optionsopt) → {String|Date}
日期格式转换函数
Example
// 当前时间减少一天, 并转换格式
date(new Date(), 'yyyy-MM-dd', {d: -1})
Parameters:
Name | Type | Attributes | Description | |||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
dateStr |
String | Date | 日期时间对象或字符串 |
||||||||||||||||||||||
format |
String |
<optional> |
输出格式,yyyy-MM-dd hh:mm:ss |
|||||||||||||||||||||
options |
Object |
<optional> |
时间偏移对象,可选 {y,M,d,h,m,s} Properties
|
Returns:
如不传递format,即返回Date类型
- Type
- String | Date
module:$ui/utils/mock(item)
根据mock配置规则,设置拦截请求返回模拟数据
Example
import mock from '@/utils/mock'
mock({
title: 'GET_USERS',
url: GET_USERS,
method: 'get',
params: {},
template: {
code: 0,
msg: '获取成功',
data: {
'id': '@guid',
'name': '@cname'
}
}
})
Parameters:
Name | Type | Description | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
item |
Object | mock规则对象 Properties
|
module:$ui/utils/skin(app, isMaster) → {Object}
Skin Mixin 构造函数
Parameters:
Name | Type | Description |
---|---|---|
app |
string | 子应用名称,可选,不设置就表示是主应用 |
isMaster |
boolean | 主题名称跟随主应用,可选,默认app独立 |
Returns:
- Type
- Object
module:$ui/utils/tween(startValue, endValue, during, easingFunc, stepCb) → {Promise}
缓动动画函数
Example
import tween, {easeInCubic} from '@/utils/tween'
tween(0, 100, 300, easeInCubic, function(val){
console.log(val)
// to do something
})
Parameters:
Name | Type | Description |
---|---|---|
startValue |
number | 开始时的值 |
endValue |
number | 结束时的值 |
during |
number | 动画持续时间,单位:毫秒 |
easingFunc |
function | 缓动算法函数 |
stepCb |
function | 每次改变的回调函数 |
Returns:
Promise实例
- Type
- Promise