-
Notifications
You must be signed in to change notification settings - Fork 915
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
vue hoc不显示插槽 #307
Comments
//成功代码 import * as R from "ramda";
//重载vnodes的方式
const how2ReloadVnodes = that =>
R.compose(R.forEach(vnode => (vnode.context = that._self)));
//用xxxxx组合slots
const composeSlotsWith = how => fromWho =>
R.compose(R.map(how(fromWho)), R.values);
export const WithConsole = something => WrappedComponent => {
return {
mounted() {
console.log(`I have already ${something}`);
},
props: WrappedComponent.props,
render(createElement) {
const { $slots, $listeners, $props, $scopedSlots, $attrs } = this;
const slots = composeSlotsWith(how2ReloadVnodes)(this)($slots);
// 什么是vue的 h(createElement)函数 见 https://segmentfault.com/a/1190000020526322*/
return createElement(
WrappedComponent,
{
on: $listeners,
props: $props,
scopedSlots: $scopedSlots,
attrs: $attrs,
},
slots
);
},
};
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
vue hoc那边$slots里面的vnode是数组不是对象
vnode是一个数组,改为⬇️
The text was updated successfully, but these errors were encountered: