更新记录
1.0.7(2021-09-29) 下载此版本
v1.0.7
轻量包,未压缩 16k,压缩 4k 使用状态机编写词法分析 动态执行表达式 调用方法支持传入 Int 调用方法支持传入 String 支持传入多个参数 支持嵌套调用 语法错误检查 支持链式调用、链式访问
平台兼容性
uni-app
| Vue2 | Vue3 | Chrome | Safari | app-vue | app-nvue | Android | iOS | 鸿蒙 |
|---|---|---|---|---|---|---|---|---|
| √ | √ | √ | √ | √ | √ | - | - | - |
| 微信小程序 | 支付宝小程序 | 抖音小程序 | 百度小程序 | 快手小程序 | 京东小程序 | 鸿蒙元服务 | QQ小程序 | 飞书小程序 | 快应用-华为 | 快应用-联盟 |
|---|---|---|---|---|---|---|---|---|---|---|
| √ | √ | √ | √ | - | - | - | √ | - | √ | √ |
其他
| 多语言 | 暗黑模式 | 宽屏模式 |
|---|---|---|
| × | × | √ |
Ctxexp Parser
上下文表达式解析器
在不能动态执行 JS 语言的环境(微信小程序)里执行类 JS 的调用函数。
Feature
- [x] 轻量包,未压缩 16k,压缩 4k
- [x] 使用状态机编写词法分析
- [x] 动态执行表达式
- [x] 调用方法支持传入 Int
- [x] 调用方法支持传入 String
- [ ] 调用方法支持传入 Function
- [x] 支持传入多个参数
- [x] 支持嵌套调用
- [x] 语法错误检查
- [x] 支持链式调用、链式访问
Tip
- 不支持在表达式中使用空格 如
$.fn(1, 2)
Install
npm i ctxexp-parser
# yarn add ctxexp-parser
Uses
import CtxexpParser from "ctxexp-parser";
// const CtxexpParser = require("ctxexp-parser");
const $ = {
a: "hello",
fn(str, str2) {
return str + str2;
},
};
const exp = `$.a`;
const res = new CtxexpParser($, exp).exec();
console.log(res); // hello
const exp1 = `$.fn($.a," cxtexp")`;
const res1 = new CtxexpParser($, exp1).exec();
console.log(res1); // hello cxtexp
About
MIT License

收藏人数:
https://github.com/WumaCoder/ctxexp-parser
https://www.npmjs.com/package/ctxexp-parser
下载插件并导入HBuilderX
下载插件ZIP
赞赏(0)
下载 57
赞赏 0
下载 10719572
赞赏 1797
赞赏
京公网安备:11010802035340号