wechat-miniprogram / j-component Goto Github PK
View Code? Open in Web Editor NEWa mock minprogram component framework
License: MIT License
a mock minprogram component framework
License: MIT License
如题,例如我需要测试一个类 button 组件,我需要渲染其文字内容,形如:
create(button, {
children: 'Button Text'
})
现在的 create
方法(以及 miniprogram-simulate
的 render
方法)似乎并不支持
为什么不同步更新呢
目前的 j-component
不支持小程序内置的behavior wx://form-field
和 wx://component-export
,导致 simulate 也不支持相关特性。
这里是否可以通过替换默认的behavior来支持该特性?
而且querySelector也取不到实例啦。
console.error node_modules/miniprogram-exparser/exparser.min.js:1 TypeError: Cannot read property 'parentNode' of undefined
请问有测试页面逻辑的方法吗? 这个库可以用作component的测试已经很赞了,可是我还想要一个测试page的方法,请问有吗?
github地址:https://github.com/hopperhuang/miniprogram-reactive
这是我自己写的一个用于小程序的computed和watch,类似于vue的实现,通过监听this.data属性的getter和setter来实现的。
单元测试,initcomponent是报错的,component.setdata的时候,并没有触发this.data的setter,所以computed和watch并没有触发。
我的代码在小程序的开发工具上跑是没有问题的,具体的例子在examples/miniprogram里面,可以跑起来看看效果
不支持模拟小程序的picker-view-column组件吗
在使用小程序运行时增强框架时,框架会提供computed watch等语法,这些语法糖是在组件attached生命周期注入相应的mixin实现,在第一次jComponent.create执行时,相应的data对象中并不存在wx:for所取数据,会在执行list.length时报错,所以希望这里加一个默认空数组的兜底逻辑。
我尝试给项目提pr,但并无项目权限,具体改动在 src/template/virtualnode.js 207行
const list = expr.calcExpression(statement.for, data)
// 修改为
const list = expr.calcExpression(statement.for, data) || []
辛苦review支持
hi 你好,我有个疑问,希望你帮帮我看看。
关于自定义组件,因为组件系统是在渲染层实现,但是原则上用户的逻辑代码在逻辑层执行,我比较疑惑的是自定义组件是如何实现的,即自定义组件在哪一层实例化,如何通信?
selectorquery exec 中获取到的node可能为null,对于node属性取值时有可能会报错
具体改动在 j-component/src/tool/selectquery.js 119行
for (const node of nodes) {
const itemRes = {}
// 修改为
for (const node of nodes) {
if (!node) continue
const itemRes = {}
辛苦review支持
创建component怎么设置data-xxx的属性?
目前我的做法是正则匹配到带有src的wxs标签,用读取到外链文件内容后,replace掉原来的wxs标签内容:
替换前:
<wxs src="../../common/wxs/array.wxs" module="utils" />
<view>{{utils.xxx}}</view>
替换后:
<wxs module="utils" />
// 这里是common/wxs/array.wxs文件内容
</wxs>
<view>{{utils.xxx}}</view>
这样做效率挺低的,基本上每个文件都是外链wxs,都需要替换一下,作者有更好的思路吗?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.