小程序
小游戏
企业微信
微信支付
扫描小程序码分享
1 个回答
加粗
标红
插入代码
插入链接
插入图片
上传视频
获取干什么
===========================
svg源码里就有
wx.request({ url: 'http://service-gw.winside.com:8080/uploadFile/map/8a51523e-1ab2-41f3-83e8-c46d1be674af.svg', success(res) { // <svg height="" width="" var r1 = /(?:[\S\s]+)?<svg(?=.*(height)="(\d+)(?:[^"]+)?")(?=.*(width)="(\d+)(?:[^"]+)?")(?:[\S\s]+)?/, // <svg viewBox="0 0 1103 711" r2 = /(?:[\S\s]+)?viewBox="\d+ \d+ (\d+) (\d+)"(?:[\S\s]+)?/, // <svg style="height:***px;width:***px" r3 = /(?:[\S\s]+)?(?:<svg[^>]+style="(?=.*(height):(\d+)(?:[^>]+)?)(?=.*(width):(\d+)(?:[^>]+)?))(?:[\S\s]+)?/, str = '{}', def = { width: 0, height: 0 }, info = false try { str = res.data.replace(r1, '{"$1":$2,"$3":$4}').replace(/\$(2|4)/, '0').replace(/\$1/, 'height').replace(/\$3/, 'width') info = str.length > 45 ? false : JSON.parse(str) if (!info) { str = res.data.replace(r2, '{"width":$1,"height":$2}').replace(/\$(1|2)/, '0') info = str.length > 45 ? false : JSON.parse(str) console.log('r2', info) } if (!info) { str = res.data.replace(r3, '{"$1":$2,"$3":$4}').replace(/\$(2|4)/, '0').replace(/\$1/, 'height').replace(/\$3/, 'width') info = str.length > 45 ? false : JSON.parse(str) console.log('r3', info) } } catch (e) { console.log(e) info = { width: 0, height: 0 } } info = info == false ? def : info console.log('ret', info) } })
若认为该回答有用,给回答者一个[ 有用 ]吧!
你好,麻烦通过点击下方“反馈信息”按钮,提供出现问题的。
wx.request({
url: 'http://service-gw.winside.com:8080/uploadFile/map/8a51523e-1ab2-41f3-83e8-c46d1be674af.svg',
success(res) {
// <svg height="" width=""
var r1 = /(?:[\S\s]+)?<svg(?=.*(height)="(\d+)(?:[^"]+)?")(?=.*(width)="(\d+)(?:[^"]+)?")(?:[\S\s]+)?/,
// <svg viewBox="0 0 1103 711"
r2 = /(?:[\S\s]+)?viewBox="\d+ \d+ (\d+) (\d+)"(?:[\S\s]+)?/,
// <svg style="height:***px;width:***px"
r3 = /(?:[\S\s]+)?(?:<svg[^>]+style="(?=.*(height):(\d+)(?:[^>]+)?)(?=.*(width):(\d+)(?:[^>]+)?))(?:[\S\s]+)?/,
str = '{}',
def = { width: 0, height: 0 },
info = false
try {
str = res.data.replace(r1, '{"$1":$2,"$3":$4}').replace(/\$(2|4)/, '0').replace(/\$1/, 'height').replace(/\$3/, 'width')
info = str.length > 45 ? false : JSON.parse(str)
if (!info) {
str = res.data.replace(r2, '{"width":$1,"height":$2}').replace(/\$(1|2)/, '0')
console.log('r2', info)
}
str = res.data.replace(r3, '{"$1":$2,"$3":$4}').replace(/\$(2|4)/, '0').replace(/\$1/, 'height').replace(/\$3/, 'width')
console.log('r3', info)
} catch (e) {
console.log(e)
info = { width: 0, height: 0 }
info = info == false ? def : info
console.log('ret', info)
})
关注后,可在微信内接收相应的重要提醒。
请使用微信扫描二维码关注 “微信开放社区” 公众号
获取干什么
===========================
svg源码里就有
wx.request({ url: 'http://service-gw.winside.com:8080/uploadFile/map/8a51523e-1ab2-41f3-83e8-c46d1be674af.svg', success(res) { // <svg height="" width="" var r1 = /(?:[\S\s]+)?<svg(?=.*(height)="(\d+)(?:[^"]+)?")(?=.*(width)="(\d+)(?:[^"]+)?")(?:[\S\s]+)?/, // <svg viewBox="0 0 1103 711" r2 = /(?:[\S\s]+)?viewBox="\d+ \d+ (\d+) (\d+)"(?:[\S\s]+)?/, // <svg style="height:***px;width:***px" r3 = /(?:[\S\s]+)?(?:<svg[^>]+style="(?=.*(height):(\d+)(?:[^>]+)?)(?=.*(width):(\d+)(?:[^>]+)?))(?:[\S\s]+)?/, str = '{}', def = { width: 0, height: 0 }, info = false try { str = res.data.replace(r1, '{"$1":$2,"$3":$4}').replace(/\$(2|4)/, '0').replace(/\$1/, 'height').replace(/\$3/, 'width') info = str.length > 45 ? false : JSON.parse(str) if (!info) { str = res.data.replace(r2, '{"width":$1,"height":$2}').replace(/\$(1|2)/, '0') info = str.length > 45 ? false : JSON.parse(str) console.log('r2', info) } if (!info) { str = res.data.replace(r3, '{"$1":$2,"$3":$4}').replace(/\$(2|4)/, '0').replace(/\$1/, 'height').replace(/\$3/, 'width') info = str.length > 45 ? false : JSON.parse(str) console.log('r3', info) } } catch (e) { console.log(e) info = { width: 0, height: 0 } } info = info == false ? def : info console.log('ret', info) } })
若认为该回答有用,给回答者一个[ 有用 ]吧!
wx.request({
url: 'http://service-gw.winside.com:8080/uploadFile/map/8a51523e-1ab2-41f3-83e8-c46d1be674af.svg',
success(res) {
// <svg height="" width=""
var r1 = /(?:[\S\s]+)?<svg(?=.*(height)="(\d+)(?:[^"]+)?")(?=.*(width)="(\d+)(?:[^"]+)?")(?:[\S\s]+)?/,
// <svg viewBox="0 0 1103 711"
r2 = /(?:[\S\s]+)?viewBox="\d+ \d+ (\d+) (\d+)"(?:[\S\s]+)?/,
// <svg style="height:***px;width:***px"
r3 = /(?:[\S\s]+)?(?:<svg[^>]+style="(?=.*(height):(\d+)(?:[^>]+)?)(?=.*(width):(\d+)(?:[^>]+)?))(?:[\S\s]+)?/,
str = '{}',
def = { width: 0, height: 0 },
info = false
try {
str = res.data.replace(r1, '{"$1":$2,"$3":$4}').replace(/\$(2|4)/, '0').replace(/\$1/, 'height').replace(/\$3/, 'width')
info = str.length > 45 ? false : JSON.parse(str)
if (!info) {
str = res.data.replace(r2, '{"width":$1,"height":$2}').replace(/\$(1|2)/, '0')
info = str.length > 45 ? false : JSON.parse(str)
console.log('r2', info)
}
if (!info) {
str = res.data.replace(r3, '{"$1":$2,"$3":$4}').replace(/\$(2|4)/, '0').replace(/\$1/, 'height').replace(/\$3/, 'width')
info = str.length > 45 ? false : JSON.parse(str)
console.log('r3', info)
}
} catch (e) {
console.log(e)
info = { width: 0, height: 0 }
}
info = info == false ? def : info
console.log('ret', info)
}
})