Vue.combile got warning when template contains slots
Vue version
3.2.35
Link to minimal reproduction
https://codepen.io/Marchcn/pen/GRQvNbZ
Steps to reproduce
See this pls, https://codepen.io/Marchcn/pen/GRQvNbZ and you will get 5 warnings from comsole.
What is expected?
no warnning and faster
What is actually happening?
Warning happend below, and sth cause it very slow in performance
vue.global.js:1616 [Vue warn]: Property undefined was accessed during render but is not defined on instance.
System Info
No response
Any additional comments?
I am migrating my test project from vue2 to vue3, and I need lots of dymatic compile in my project, lots of warning make page performance very bad!
and I found that there are 1.5 times more doms generated in vue3 than vue2 in test project, and less performance
- There is no version of Vue that supports the
:scope
syntax on slots. - The
slot-scope
syntax has been deprecated since 2.6 and no longer supported in Vue 3. Please read relevant sections on slots in Vue 3 docs. - Runtime compiler performance is likely slower in Vue 3 because it does more work to apply more optimizations (in return for better component update performance). This is by design.
- There is no version of Vue that supports the
:scope
syntax on slots.- The
slot-scope
syntax has been deprecated since 2.6 and no longer supported in Vue 3. Please read relevant sections on slots in Vue 3 docs.- Runtime compiler performance is likely slower in Vue 3 because it does more work to apply more optimizations (in return for better component update performance). This is by design.
thanks for reply !
I think It made confused as prop has been named 'scope' ,
warnning still exists when compiling the emplate defined as
<div v-for="i in 5"><slot :p1="{index:i}"></slot></div>
and I updated in CodePen here, https://codepen.io/Marchcn/pen/GRQvNbZ,
by the way, I found another issue here https://github.com/vuejs/test-utils/issues/549#issuecomment-847956416 with the similar problem, may be helpful for this
This is weird usage because you are using the compiled function inside a custom render function instead of using it directly:
{
render: function(){
let r = Vue.compile(`<div v-for="i in 5"><slot :p1="{index:i}">default</slot></div>`);
return r(this);
}
}
I don't know why you are doing this, but you should be doing this instead:
{
render: Vue.compile(`<div v-for="i in 5"><slot :p1="{index:i}">default</slot></div>`)
}
Runtime-compiled render functions need special handling, but Vue won't know it's runtime-compiled unless it's a function directly returned by Vue.compile
.