babel-plugin-transform-vue-jsx
babel-plugin-transform-vue-jsx copied to clipboard
When a functional component is inserted outside of the document(#app), the context is not available within the component.
//src/index.vue
export default {
functional:true,
props:{
styObj:{
type:Object,
default(){
return {
width:'300px',
height:'300px'
}
}
},
title:{
type:String,
default:'00'
}
},
render(h,context){
return(
<div class="dialog" >
{context.props.title}
</div>
)
}
}
and import compoent
import com from './src'
const Dia=Vue.extend(com)
const vm=new Dia()
vm.$mount()
document.body.appendChild(vm.$el)
but it cant't work errors: context.props.title is undefined
Yes, I found the same problem, too. But it can be used as long as it is ‘import’ inside the component. 要重新局部引入才能用,因为不复杂,果断用render普通语法了。
This still exists in version 2.5.17. Same use case as OP.