提交 6e941c0d 编写于 作者: L liuxiaohang

fix(h5): 修复在 微信环境里 chooseFile 默认值提示 没有应用可执行此操作

上级 fab98deb
import { updateElementStyle } from 'uni-shared'
const ALL = '*'
function isWXEnv () {
const ua = window.navigator.userAgent.toLowerCase()
if (ua.match(/MicroMessenger/i) && ua.match(/MicroMessenger/i)[0] === 'micromessenger') {
return true
} else {
return false
}
}
export default function ({ count, sourceType, type, extension }) {
const inputEl = document.createElement('input')
......@@ -15,10 +25,14 @@ export default function ({ count, sourceType, type, extension }) {
})
inputEl.accept = extension.map(item => {
if (type !== '*') {
if (type !== ALL) {
// 剔除.拼接在type后
return `${type}/${item.replace('.', '')}`
} else {
// 在微信环境里,'.jpeg,.png' 会提示没有应用可执行此操作
if (isWXEnv()) {
return '.'
}
// 在后缀前方加上.
return item.indexOf('.') === 0 ? item : `.${item}`
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册