Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mpvue-router-patch 引用的 query-string ios10版本兼容问题 #7

Closed
ltinyho opened this issue May 9, 2018 · 8 comments
Closed

Comments

@ltinyho
Copy link

ltinyho commented May 9, 2018

wechatimg1
因为使用了mpvue-router-patch包,但是并没有经过babel处理,导致打包后的vendor.js包含const,经测试,在ios 10版本及以下会出现如图错误。

 {
        test: /\.js$/,
        loader: 'babel-loader?cacheDirectory=true',
        include: [
          /node_modules\/.*mpvue-router-patch.*/,
          // /node_modules\/.*query-string.*/,
        ],
      },
}

我的解决办法是使用babel-loader处理,但是mpvue-router-patch引用的query-string这个包也是使用了const,没有经过babel处理。我将query-string也同样处理后,但是query-string并不是使用es6写法,不知道怎么处理了。

import queryString from 'query-string';
const queryStr = queryString.stringify(query, { encode: false })

改为
import queryString from 'querystring';
const queryStr = queryString.stringify(query)

我将query-string替换为querystring解决了兼容问题。请问怎样配置能解决这个问题的。

@F-loat
Copy link
Owner

F-loat commented May 9, 2018

可以打开开发工具的 es6 转换试下,另外 mpvue-router-patch 这个库我晚点提供一个 es5 的版本

@ltinyho
Copy link
Author

ltinyho commented May 10, 2018

开发工具转es6会报错,因为我其他的包已经转过了,能提供es5版本的最好了

@F-loat
Copy link
Owner

F-loat commented May 10, 2018

这个库好说,组件库不知道有没有类似的问题

@ltinyho
Copy link
Author

ltinyho commented May 10, 2018

就是query-string这个包引起的,能用node提供的querystring包吗,或者降低query-string到5.0的版本,这个是用es5写的,6.0不兼容版本的

@F-loat
Copy link
Owner

F-loat commented May 10, 2018

可以换成 querystring,同时我这边也得转成 es5 吧

@ltinyho
Copy link
Author

ltinyho commented May 10, 2018

感谢

@F-loat
Copy link
Owner

F-loat commented May 10, 2018

好了应该,我这边简单测了下没问题

@ltinyho
Copy link
Author

ltinyho commented May 10, 2018

嗯嗯,成功解决兼容问题,👍。

@ltinyho ltinyho closed this as completed May 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants