# mg-parse-query

> 例如: `http:localhost:3306?serviceTimezone=UTF&age=20`

Latest version **1.0.2** (published 2021-12-29) · ISC license · 0 weekly downloads

## Install

```sh
npm install mg-parse-query
pnpm add mg-parse-query
yarn add mg-parse-query
bun add mg-parse-query
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2021-12-29 |
| First published | 2021-11-02 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 3.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | 方明光 |
| Maintainers | fmg0224 |
| Keywords | 解析url地址, url地址, http参数处理 |

## Links

- npm: https://www.npmjs.com/package/mg-parse-query
- npm.io page: https://npm.io/package/mg-parse-query

## Alternatives

- [base64url](https://npm.io/package/base64url.md) — 6.1M weekly downloads
- [get-installed-path](https://npm.io/package/get-installed-path.md) — 502.9K weekly downloads
- [@uppy/url](https://npm.io/package/@uppy/url.md) — 185.8K weekly downloads
- [@d3fc/d3fc-shape](https://npm.io/package/@d3fc/d3fc-shape.md) — 16.2K weekly downloads
- [localizer](https://npm.io/package/localizer.md) — 226 weekly downloads

## Recent versions

- 1.0.2 (latest) — 2021-12-29
- 1.0.1 — 2021-12-29
- 1.0.0 — 2021-11-02

## README

### `vue`项目中解析`url`地址栏参数用, 包括 使用 `vue` 构建的小程序, 例如 `uniapp`

使用方法

```javascript
// 1. 安装包
npm i mp-parse-query

// 2. 在 vue 文件中
import ParseQuery from 'mp-parse-query'

// 3. 使用
const result = ParseQuery('需要解析的http字符串')
```

#### 注意事项

能解析的 http 字符串 示例

```javascript
// http://www.baidu.com?name=zs   =>
result = { name: "zs", url: "http://www.baidu.com" };
// http://www.baidu.com?name=zs&age=15  =>
result = { name: "zs", age: "15", url: "http://www.baidu.com" };
// http://www.baidu.com?url=page4   =>
result = { url: "page4", _url: "http://www.baidu.com" };
// name=zs&age=15  =>
result = { name: "zs", age: "15" };
// name=zs =>
result = { name: "zs" };
```

```javascript
// 如果地址栏中, 携带了 url 地址, 原来的 url 地址会被解析成 对象的 _url
```

```javascript
// 如果直接传入一个不带 = 符号的字符串, 该字符串会被解析成 对象的 键, 值为 undefined
```

```javascript
// 报错会返回 {}
```

```javascript
// 有问题 请邮箱至  fmg0224@163.com
```

---
_Source: https://npm.io/package/mg-parse-query · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
