提交 02acfe73 编写于 作者: fxy060608's avatar fxy060608

refactor(mp): improve render props

上级 c8476f73
......@@ -149,8 +149,7 @@ function createEmitFn(oldEmit, ctx) {
}
}
{
const vnode = this.$.vnode;
const props = vnode && vnode.props;
const props = scope.props;
if (props && props[`on${capitalize(event)}`]) {
return;
}
......@@ -756,11 +755,8 @@ function triggerEvent(type, detail) {
if (!handler) {
return;
}
const eventOpts = this.props['data-event-opts'];
const target = {
dataset: {
eventOpts,
},
dataset: {},
};
handler({
type: customize(type),
......
......@@ -4749,6 +4749,8 @@ function renderComponentRoot(instance) {
instance.$ei = 0;
// props
pruneComponentPropsCache(uid);
instance.__counter =
instance.__counter === 0 ? 1 : 0;
let result;
const prev = setCurrentRenderingInstance(instance);
try {
......@@ -5076,10 +5078,10 @@ function initApp(app) {
const propsCaches = Object.create(null);
function renderProps(props) {
const { uid } = getCurrentInstance();
const { uid, __counter } = getCurrentInstance();
const propsId = (propsCaches[uid] || (propsCaches[uid] = [])).push(guardReactiveProps(props)) - 1;
// 强制每次更新
return uid + ',' + propsId + ',' + Math.random();
return uid + ',' + propsId + ',' + __counter;
}
function pruneComponentPropsCache(uid) {
delete propsCaches[uid];
......
......@@ -4749,6 +4749,8 @@ function renderComponentRoot(instance) {
instance.$ei = 0;
// props
pruneComponentPropsCache(uid);
instance.__counter =
instance.__counter === 0 ? 1 : 0;
let result;
const prev = setCurrentRenderingInstance(instance);
try {
......
import { getCurrentInstance, guardReactiveProps } from 'vue'
import {
ComponentInternalInstance,
getCurrentInstance,
guardReactiveProps,
} from 'vue'
const propsCaches: Record<string, Record<string, any>[]> = Object.create(null)
export function renderProps(props: Data) {
const { uid } = getCurrentInstance()!
const { uid, __counter } =
getCurrentInstance()! as ComponentInternalInstance & {
__counter: number
}
const propsId =
(propsCaches[uid] || (propsCaches[uid] = [])).push(
guardReactiveProps(props)!
) - 1
// 强制每次更新
return uid + ',' + propsId + ',' + Math.random()
return uid + ',' + propsId + ',' + __counter
}
export function pruneComponentPropsCache(uid: number) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册