Vue将xml格式转为json (x2js.js)

1.npm安装x2js
npm i x2js(报错的话下面有解决方法)

2.全局挂载main.js
import x2js from ‘x2js’ //xml数据处理插件
Vue.prototype.$x2js = new x2js() //全局方法挂载

3.使用 
var jsonObj = this.$x2js.xml2js(res);//res (xml数据)
console.log(jsonObjt); 

1.

package name: (22324) package
version: (1.0.0) 6.14.4
description: 包名6.14.4
entry point: (index.js) index.js
test command: npm test
keywords: 123456
author: ***
license: (ISC) 无
Sorry, license should be a valid SPDX license expression (without "LicenseRef"), "UNLICENSED", or "SEE LICENSE IN <filename>".
license: (ISC) 许可证
Sorry, license should be a valid SPDX license expression (without "LicenseRef"), "UNLICENSED", or "SEE LICENSE IN <filename>".
license: (ISC) BSD-2-Clause
About to write to C:\Users\22324\package.json:

{
  "name": "package",
  "version": "6.14.4",
  "description": "包名6.14.4",
  "main": "index.js",
  "dependencies": {
    "js-base64": "^2.6.3",
    "x2js": "^3.4.0"
  },
  "devDependencies": {},
  "scripts": {
    "test": "npm test"
  },
  "repository": {
    "type": "git",
    "url": "npm test"
  },
  "keywords": [
    "123456"
  ],
  "author": "***",
  "license": "BSD-2-Clause"
}

Is this OK? (yes) y

C:\Users\22324>npm i x2js
+ [email protected]
removed 21 packages, updated 1 package and audited 3 packages in 2.527s
found 0 vulnerabilities

Vue将xml格式转为json (x2js.js)

Vue将xml格式转为json (x2js.js)

Vue将xml格式转为json (x2js.js)